| | |
| | | package com.fgkj.services; |
| | | |
| | | import com.fgkj.dto.BattInf; |
| | | import com.fgkj.dto.Batttestdata_inf; |
| | | import com.fgkj.dto.DLG_Progress; |
| | | import com.fgkj.dto.User_inf; |
| | | import com.fgkj.fbo.FboData; |
| | | import com.fgkj.fbo.FboDataInf; |
| | | import com.fgkj.fbo.IdcData; |
| | | import com.fgkj.mapper.impl.BattInfMapper; |
| | | import com.fgkj.mapper.impl.Batttestdata_infMapper; |
| | | import com.fgkj.mapper.impl.FboDataUploadMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import com.fgkj.mapper.impl.BattInfMapper; |
| | | import com.fgkj.mapper.impl.Batttestdata_infMapper; |
| | | import com.fgkj.mapper.impl.FboDataUploadImpl; |
| | | import com.fgkj.dto.BattInf; |
| | | import com.fgkj.dto.Batttestdata_inf; |
| | | import com.fgkj.dto.DLG_Progress; |
| | | import com.fgkj.dto.ServiceModel; |
| | | import com.fgkj.dto.User_inf; |
| | | import com.fgkj.fbo.FboData; |
| | | import com.fgkj.fbo.FboDataInf; |
| | | import com.fgkj.fbo.IdcData; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | /** |
| | | * fbo数据上传,TODO perry校验效果 |
| | | */ |
| | | import javax.annotation.Resource; |
| | | @Service |
| | | public class FboDataUploadService extends Thread{ |
| | | |
| | | private ServiceModel model; |
| | | private User_inf uinf; |
| | | private int bg_id; |
| | | private String[][] tableRowData; |
| | | private File[] file; |
| | | private HttpSession session; |
| | | private DLG_Progress progress; |
| | | // ServiceModel model = new ServiceModel(); |
| | | // private User_inf uinf; |
| | | // private int bg_id; |
| | | // private String[][] tableRowData; |
| | | // private File[] file; |
| | | // private HttpSession session; |
| | | // private DLG_Progress progress; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private Batttestdata_infMapper battTestDataInfMapper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private BattInfMapper battInfMapper; |
| | | |
| | | @Resource |
| | | private FboDataUploadMapper mapper; |
| | | |
| | | |
| | | public FboDataUploadService() { |
| | | model = new ServiceModel(); |
| | | /*public FboDataUploadService() { |
| | | model = new ServiceModel(); |
| | | progress=new DLG_Progress(true,false); |
| | | } |
| | | |
| | |
| | | progress.setTableData(tableRowData); |
| | | progress.setTotal(file.length); |
| | | session.setAttribute("progress", progress); |
| | | }*/ |
| | | |
| | | public void uploadFile(User_inf uinf, int bg_id, String[][] tableRowData, File[] file, HttpSession session) { |
| | | DLG_Progress progress=new DLG_Progress(true,false); |
| | | progress.setTableData(tableRowData); |
| | | progress.setTotal(file.length); |
| | | session.setAttribute("progress", progress); |
| | | |
| | | Thread thread = new Thread() { |
| | | @Override |
| | | public void run() { |
| | | for (int n = 0; n < tableRowData.length; n++) { |
| | | if (false == progress.isJudge()) { |
| | | break; |
| | | } |
| | | |
| | | if ("false".equals(tableRowData[n][2])) //是否能上传 |
| | | { |
| | | continue; |
| | | } |
| | | if ("true".equals(tableRowData[n][4])) //是否已上传 |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | //m_UploadCount++; |
| | | FboDataInf data_inf = new FboDataInf(); |
| | | ArrayList<FboData> al_fbo_data = new ArrayList<FboData>(); |
| | | |
| | | File f = file[n]; |
| | | if (tableRowData[n][1].toUpperCase().endsWith(".FBO")) { |
| | | FboData.checkFboFile(f, data_inf, al_fbo_data); |
| | | } else if (tableRowData[n][1].toUpperCase().endsWith(".IDC")) { |
| | | IdcData.checkIdcFile(f, data_inf, al_fbo_data); |
| | | } |
| | | int bg_id = Integer.parseInt((String) tableRowData[n][0]); |
| | | //判断文件是否存在 |
| | | // boolean flag=FileisUpload(bg_id, data_inf); |
| | | // if(!flag){ |
| | | // continue; |
| | | // } |
| | | |
| | | Boolean bl = mapper.uploadFboData(uinf, bg_id, data_inf, al_fbo_data, tableRowData[n], progress.isJudge()); |
| | | if (true == bl) { |
| | | //System.out.println(bg_id+"\t"+bl); |
| | | tableRowData[n][4] = "true"; |
| | | progress.setUploadOkcount(progress.getUploadOkcount() + 1); |
| | | } |
| | | |
| | | } |
| | | for (File fl : file) { |
| | | if (fl.exists()) { |
| | | fl.delete(); |
| | | } |
| | | } |
| | | progress.setCompleteed(true); |
| | | progress.setJudge(false); |
| | | } |
| | | }; |
| | | thread.start(); |
| | | |
| | | } |
| | | |
| | | public void run(){ |
| | | /*public void run(){ |
| | | //System.out.println("开启线程"); |
| | | //System.out.println(progress); |
| | | for(int n=0; n<tableRowData.length; n++) |
| | |
| | | } |
| | | progress.setCompleteed(true); |
| | | progress.setJudge(false); |
| | | } |
| | | } */ |
| | | //判断当前文件能否上传 |
| | | /** |
| | | * |
| | |
| | | } |
| | | return data_ok; |
| | | } |
| | | |
| | | public void stopUpload(){ |
| | | progress.setJudge(false); |
| | | } |
| | | |
| | | public String[][] getTableRowData() { |
| | | return tableRowData; |
| | | } |
| | | |
| | | public void setTableRowData(String[][] tableRowData) { |
| | | this.tableRowData = tableRowData; |
| | | } |
| | | } |