lxw
2022-03-24 77b22de1089c57593a9ec23dddd541f37e0f071b
//A059一体机导出文件名
2个文件已修改
161 ■■■■■ 已修改文件
src/com/fgkj/dao/impl/BattInfImpl.java 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/fgkj/servlets/EchartPictureDowloadServlet.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/fgkj/dao/impl/BattInfImpl.java
@@ -3536,6 +3536,44 @@
        });
        return list;
    }
    //取出电池组信息构建excel文件的名称
    public String serchExcelName(int battGroupId) {
        String sql = " select distinct stationName1,stationName2,stationName3,stationName5,BattProducer," +
                " battproductdate,MonCapStd,BattGroupName " +
                " from db_battinf.tb_battinf " +
                " where  db_battinf.tb_battinf.battGroupId=?  limit 1";
        List list = DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{battGroupId}, new CallBack() {
            public List getResults(ResultSet rs) {
                List list = new ArrayList();
                try {
                    while (rs.next()) {
                        BattInf binf = new BattInf();
                        binf.setStationName1(rs.getString("stationName1"));
                        binf.setStationName2(rs.getString("stationName2"));
                        binf.setStationName3(rs.getString("stationName3"));
                        binf.setStationName5(rs.getString("stationName5"));
                        binf.setBattProducer(rs.getString("BattProducer"));
                        binf.setBattProductDate(rs.getDate("battproductdate"));
                        binf.setMonCapStd(rs.getFloat("MonCapStd"));
                        binf.setBattGroupName(rs.getString("BattGroupName"));
                        list.add(binf);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        String excelName="";
        if(list!=null&&list.size()>0){
            BattInf binf= (BattInf) list.get(list.size()-1);
            excelName=binf.getStationName1()+"-"+binf.getStationName2()+"-"+binf.getStationName5()+"-"+binf.getStationName3()
                     +"-"+DAOHelper.sdfwithOut.format(binf.getBattProductDate())+"-"+(int)((float)binf.getMonCapStd())+"AH"+"-"+binf.getBattGroupName();
        }
        return excelName;
    }
    /**
     * 根据机房id查询电池组
@@ -4398,57 +4436,6 @@
        return list;
    }
    public static void main(String[] args) throws ParseException {
        //new BattInfImpl().searchAll();
        BattInfImpl biml = new BattInfImpl();
        BattInf binf = new BattInf();
        binf.setNum(1002);
        binf.setBattGroupId(0);
        binf.setStationName("内蒙古");
        binf.setStationName1("");
        binf.setStationName2("");
        binf.setStationName5("");
        binf.setStationName3("");
        binf.setStationId("42070450");
        User_inf uinf = new User_inf();
        uinf.setUId(1002);
        Page p = new Page();
        p.setPageCurr(1);
        p.setPageSize(50);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2000-01-01");
        Date date2 = sdf.parse("2020-01-01");
        Batttestdata_inf tdata = new Batttestdata_inf();
        tdata.setTest_type(3);
        tdata.setTest_starttype(3);
        tdata.setRecord_time(ActionUtil.getSimpDate(date1));
        tdata.setRecord_time1(ActionUtil.getSimpDate(date2));
        Batt_Maint_Dealarm bmd = new Batt_Maint_Dealarm();
        bmd.setBinf(binf);
        bmd.setPage(p);
        bmd.setTdata(tdata);
        bmd.setUinf(uinf);
        //List<BattInf> list = biml.serchByConditionNew(bmd);
        //List<BattInf> list=biml.serchByTestType(bmd);
        /*List<BattInf> list=biml.serchGroupAssess(bmd);
        for (BattInf b : list) {
            System.out.println(b);
        }*/
        /*List<BattInf> list=biml.serchBattPlan(binf);
        for (BattInf b : list) {
            System.out.println(b.getBattGroupId()+"  "+b.getFBSDeviceId()+" "+b.getFparam());
        }*/
        //List list=biml.searchDevByStationName3(binf);
        List list = biml.serchBattAllInfoByStationId(binf);
        System.out.println(list.size());
    }
    public List findBattProducer(int uId) {
        String sql = "select BattProducer,count(BattProducer) as num from db_battinf.tb_battinf ";
        String userSql = "where StationId in(select distinct db_battinf.tb_battinf.StationId " +
@@ -5052,4 +5039,57 @@
        });
        return list;
    }
    public static void main(String[] args) throws ParseException {
        //new BattInfImpl().searchAll();
        BattInfImpl biml = new BattInfImpl();
        BattInf binf = new BattInf();
        binf.setNum(1002);
        binf.setBattGroupId(0);
        binf.setStationName("内蒙古");
        binf.setStationName1("");
        binf.setStationName2("");
        binf.setStationName5("");
        binf.setStationName3("");
        binf.setStationId("42070450");
        User_inf uinf = new User_inf();
        uinf.setUId(1002);
        Page p = new Page();
        p.setPageCurr(1);
        p.setPageSize(50);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2000-01-01");
        Date date2 = sdf.parse("2020-01-01");
        Batttestdata_inf tdata = new Batttestdata_inf();
        tdata.setTest_type(3);
        tdata.setTest_starttype(3);
        tdata.setRecord_time(ActionUtil.getSimpDate(date1));
        tdata.setRecord_time1(ActionUtil.getSimpDate(date2));
        Batt_Maint_Dealarm bmd = new Batt_Maint_Dealarm();
        bmd.setBinf(binf);
        bmd.setPage(p);
        bmd.setTdata(tdata);
        bmd.setUinf(uinf);
        //List<BattInf> list = biml.serchByConditionNew(bmd);
        //List<BattInf> list=biml.serchByTestType(bmd);
        /*List<BattInf> list=biml.serchGroupAssess(bmd);
        for (BattInf b : list) {
            System.out.println(b);
        }*/
        /*List<BattInf> list=biml.serchBattPlan(binf);
        for (BattInf b : list) {
            System.out.println(b.getBattGroupId()+"  "+b.getFBSDeviceId()+" "+b.getFparam());
        }*/
        //List list=biml.searchDevByStationName3(binf);
        //List list = biml.serchBattAllInfoByStationId(binf);
        //System.out.println(list.size());
        String excelName=biml.serchExcelName(1000061);
        System.out.println(excelName);
    }
}
src/com/fgkj/servlets/EchartPictureDowloadServlet.java
@@ -12,6 +12,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fgkj.dao.impl.BattInfImpl;
import com.fgkj.dao.impl.FbotestdataImpl;
import com.fgkj.dao.impl.Ld9.Ld9testdataImpl;
import com.fgkj.dao.impl.Ld9.Ld9testdata_infImpl;
@@ -82,6 +83,8 @@
        f.setBattGroupId(battGroupId);
        f.setTest_record_count(testRecordCount);
        List<Fbotestdata> list=new FbotestdataImpl().serchByCondition(f);  //查询4059充放电数据
        //取出电池组信息构建excel文件的名称
        String excelName =new BattInfImpl().serchExcelName(battGroupId);
        int monCount= new FbotestdataImpl().getMonCuntBytestRecordCount(f); //查询具体一次充放电单体个数
        //处理图片
@@ -102,9 +105,7 @@
        }catch (Exception e){
            e.printStackTrace();
        }
        //当前日期
        String nowFormat = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String excelName = "FGCD-"+nowFormat;
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("Sheet1");
@@ -137,12 +138,17 @@
            row.createCell(4+i).setCellValue("#"+Integer.valueOf(i+1));
        }
        rowNum++;
        //取出放电开始时间
        Date test_starttime=null ;
        //数据栏
        if(monCount!=0){
            for (int i = 0; i < list.size(); i++) {
                sheet.createRow(rowNum);  //创建行
                for(int j=0;j<monCount;j++){
                    Fbotestdata fbo=list.get(i+j);
                    if(i==0&&j==0){
                        test_starttime=fbo.getTest_starttime();
                    }
                    sheet.getRow(rowNum).createCell(0).setCellValue(ActionUtil.secToTime(fbo.getTest_timelong()));
                    sheet.getRow(rowNum).createCell(1).setCellValue(fbo.getSum_vol());
                    sheet.getRow(rowNum).createCell(2).setCellValue(fbo.getTest_curr());
@@ -154,6 +160,13 @@
            }
        }
        rowNum+=2;
        //excel文件名
        String testTime = new SimpleDateFormat("yyyy-MM-dd").format(test_starttime);
        excelName = excelName+"-"+testTime;
        String regEx="[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
        excelName = excelName.replace(regEx,"");
        //插入图片
        int picNum = 0;
        String[] picName = new String[]{