vaadin 上传下载案例

Wesley13
• 阅读 379

package com.rquest.riskmaster.component;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.rquest.riskmaster.entity.BusinessDays;
import com.rquest.riskmaster.entity.User;
import com.rquest.riskmaster.entity.UserDefiendCalendar;
import com.rquest.riskmaster.enums.SequenceEnum;
import com.rquest.riskmaster.process.MarketRiskCalendarProcess;
import com.rquest.riskmaster.util.Util;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.FileDownloader;
import com.vaadin.server.Page;
import com.vaadin.server.Page.BrowserWindowResizeEvent;
import com.vaadin.server.Page.BrowserWindowResizeListener;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.FailedEvent;
import com.vaadin.ui.Upload.FailedListener;
import com.vaadin.ui.Upload.Receiver;
import com.vaadin.ui.Upload.SucceededEvent;
import com.vaadin.ui.Upload.SucceededListener;
import com.vaadin.ui.VerticalLayout;

@Service
@Scope("prototype")
public class MarketRiskCalendarComponent extends CommonComponent implements Receiver, SucceededListener, FailedListener {
    private static final long serialVersionUID = 9087370805007811092L;
    public static final Logger logger = LoggerFactory.getLogger(MarketRiskCalendarComponent.class);

    /**
     * 日历;
     */
    // vaadin component
    private Label rptNameLb;
    private DateField date;
    private VerticalLayout reportLayout;
    private Panel mainPanel;
    private VerticalLayout thumbnailVertical;
    private List businessDays;
    private Label  space;
    private String preChangeDate;
    private Label yearAndMonth;
    private ClickListener clickListener;
    private File fileUploaded=null;//上传文件
    private Upload btnUpLoad;
    private TextField importFileName;
    private User currentUser;
    private List listDate;
    private Button download;
    
    @Autowired
    private MarketRiskCalendarProcess marketRiskCalendarProcess;

    @Override
    public void initLayout() {
        currentUser = ((User)VaadinSession.getCurrent().getAttribute("user"));
        initLayoutHeader();
        addDateTitle();
        addWeeklyCaption();
        initLayoutCalendar();
    }

    public void reSize() {
        mainPanel.setHeight((Page.getCurrent().getBrowserWindowHeight() - 150) + "px");
        mainPanel.setWidth((Page.getCurrent().getBrowserWindowWidth() ) + "px");
    }

    /**
     * Function Name : initLayoutTitleAndExport Description : 初始化标题、导出PDF、excel;
     * 
     * @author : Administrator
     */
    public void initLayoutHeader() {
        mainPanel = new Panel();
        setCompositionRoot(mainPanel);
        mainPanel.setWidth("100%");
        // mainPanel.setStyleName("daily-root-layout");
        reportLayout = new VerticalLayout();
        reportLayout.setHeight("790px");
        reportLayout.setWidth("1850px");
        mainPanel.setContent(reportLayout);

        rptNameLb = new Label("交易日历");
        rptNameLb.addStyleName("rptname");
        rptNameLb.setWidthUndefined();

        HorizontalLayout top = new HorizontalLayout();
        top.setHeight("60px");
        top.setWidth("20%");
        top.addComponent(rptNameLb);
        top.setComponentAlignment(rptNameLb, Alignment.MIDDLE_LEFT);

        HorizontalLayout topRight = new HorizontalLayout();
        topRight.addStyleName("daily-second-line");
        topRight.setSizeFull();
        topRight.setHeight("60px");
        topRight.setWidth("900px");

        Label blankLabel0 = new Label();
        blankLabel0.setWidth("100%");
        topRight.addComponent(blankLabel0);

        Label dateLb = new Label("日期:  ");
        dateLb.setStyleName("marketrisk-datelabel");
        dateLb.setWidth("40px");
        topRight.addComponent(dateLb);
        
        date = new DateField();
        date.addStyleName("marketrisk-datefield");
        topRight.addComponent(date);
        date.setValue((Date) VaadinSession.getCurrent().getAttribute("vardate"));
        date.setDateFormat("yyyy-MM-dd");
        
        Label lblAssetType=new Label("上传日历文件:");
        lblAssetType.addStyleName("marketrisk-lblassettype");
        topRight.addComponent(lblAssetType);
        lblAssetType.setWidth("100px");
        importFileName=new TextField();
        importFileName.addStyleName("marketrisk-importfilename");
        importFileName.setWidth("300px");
        importFileName.setEnabled(false);
        importFileName.setValue("请点击上传按钮并选择相应的CSV文件上传");
        topRight.addComponent(importFileName);
        
        btnUpLoad = new Upload(null,this);
        btnUpLoad.setButtonCaption("上传");
        btnUpLoad.setData("calendar");
        btnUpLoad.setImmediate(true);
        btnUpLoad.addSucceededListener(this);
        btnUpLoad.addFailedListener(this);
        btnUpLoad.setWidth("80px");
        btnUpLoad.addStyleName("marketrisk-uploadbutton");
        topRight.addComponent(btnUpLoad);
        
        download = new Button("下载模版");
        download.addStyleName("marketrisk-download");
        topRight.addComponent(download);
        
        Label blankLabel1 = new Label();
        blankLabel1.setWidth("100%");
        topRight.addComponent(blankLabel1);

//        Label blankLabel2 = new Label();
//        blankLabel2.setWidth("100%");
//        topRight.addComponent(blankLabel2);

//        topRight.setComponentAlignment(dateLb, Alignment.MIDDLE_LEFT);
//        topRight.setComponentAlignment(date, Alignment.MIDDLE_LEFT);
        topRight.setComponentAlignment(btnUpLoad, Alignment.MIDDLE_LEFT);
        topRight.setExpandRatio(blankLabel1, 1.0f);
//        topRight.setExpandRatio(blankLabel2, 1.0f);

        top.addComponent(topRight);
        top.setComponentAlignment(topRight, Alignment.MIDDLE_LEFT);
        reportLayout.addComponent(top);
    }

    private void addDateTitle() {
        HorizontalLayout dateCaption = new HorizontalLayout();
        dateCaption.setHeight("30px");
        yearAndMonth = new Label("");
        dateCaption.addComponent(yearAndMonth);
        yearAndMonth.addStyleName("marketrisk-datetitlelb");
        reportLayout.addComponent(dateCaption);
    }

    private void addWeeklyCaption() {
        GridLayout grid = new GridLayout(7,1);
        grid.addStyleName("marketrisk-grid");
        grid.addComponent(newLabel(SequenceEnum.MONDAY, "150", "white"),0,0);
        grid.addComponent(newLabel(SequenceEnum.TUESDAY, "150", "white"),1,0);
        grid.addComponent(newLabel(SequenceEnum.WEDNESDAY, "150", "white"),2,0);
        grid.addComponent(newLabel(SequenceEnum.THURSDAY, "150", "white"),3,0);
        grid.addComponent(newLabel(SequenceEnum.FRIDAY, "150", "white"),4,0);
        grid.addComponent(newLabel(SequenceEnum.SATURDAY, "150", "white"),5,0);
        grid.addComponent(newLabel(SequenceEnum.SUNDAY, "150", "white"),6,0);
        reportLayout.addComponent(grid);
    }
    public void initLayoutCalendar() {
        String format = Util.DATE_FORMATE_yyyy_MM_dd.format(date.getValue());
        if (preChangeDate!=null&&format.equals(preChangeDate)) {
                return;
        }        
        preChangeDate = format;
        String startDate = Util.getFirstDayOfMonth(format);
        String endDate = Util.getLastDayOfMonth(format);
        yearAndMonth.setValue(startDate.split("-")[0]+"年"+startDate.split("-")[1]+"月");
        businessDays = marketRiskCalendarProcess.getMonthDays("Bond_CN", startDate, endDate);
        listDate = marketRiskCalendarProcess.getUserDefiendCalendar(currentUser.getUserId(),startDate,endDate);
        businessDays= getContinousDays(businessDays);
        if (thumbnailVertical != null) {
            reportLayout.removeComponent(thumbnailVertical);
            reportLayout.removeComponent(space);
        }
        thumbnailVertical = new VerticalLayout();
        space =new Label();
        thumbnailVertical.addStyleName("marketrisk-thumbnailVertical");
        reportLayout.addComponent(thumbnailVertical);
        reportLayout.addComponent(space);
        reportLayout.setExpandRatio(space, 1);
        reportLayout.setComponentAlignment(thumbnailVertical, Alignment.MIDDLE_CENTER);
        if (setNobusinessDaysReportLayout()) {
            return;
        }

        int index = 0;
        for (int i = 0; i < businessDays.size() / 7 + 2; i++) {
            HorizontalLayout thumbnailHorizontalLayout = new HorizontalLayout();
            thumbnailHorizontalLayout.addStyleName("marketrisk-thumbnailHorizontalLayout");

            for (; index < businessDays.size();) {
                addBlankSpaceOfDays(thumbnailHorizontalLayout,index);
                generateThumbnailLayout(businessDays, index, thumbnailHorizontalLayout);
                index++;
//                if (index % 5 == 0) {
//                    break;
//                }
                if (thumbnailHorizontalLayout.getComponentCount()%7 ==0) {
                    break;
                }
            }
            thumbnailVertical.addComponent(thumbnailHorizontalLayout);
//            thumbnailVertical.setComponentAlignment(thumbnailHorizontalLayout, Alignment.MIDDLE_CENTER);
        }
    }

    private void addBlankSpaceOfDays(HorizontalLayout thumbnailHorizontalLayout,int index) {
        if (index== 0&&Util.getDayofweek(Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(index).getDtBusinessDay())).equals(SequenceEnum.TUESDAY)) {
            generateBlankLayout(thumbnailHorizontalLayout);
        }
        if (index== 0&&Util.getDayofweek(Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(index).getDtBusinessDay())).equals(SequenceEnum.WEDNESDAY)) {
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
        }
        if (index== 0&&Util.getDayofweek(Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(index).getDtBusinessDay())).equals(SequenceEnum.THURSDAY)) {
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
        }
        if (index== 0&&Util.getDayofweek(Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(index).getDtBusinessDay())).equals(SequenceEnum.FRIDAY)) {
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
        }
        if (index== 0&&Util.getDayofweek(Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(index).getDtBusinessDay())).equals(SequenceEnum.SATURDAY)) {
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
        }
        if (index== 0&&Util.getDayofweek(Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(index).getDtBusinessDay())).equals(SequenceEnum.SUNDAY)) {
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
            generateBlankLayout(thumbnailHorizontalLayout);
        }
    }
    
    private void generateThumbnailLayout(List businessDays, int index, HorizontalLayout thumbnailHorizontalLayout) {
        VerticalLayout dateVertical = new VerticalLayout();
        dateVertical.addStyleName("marketrisk-datevertical");
        Label dateLb = new Label(Util.DATE_FORMATE_dd.format(businessDays.get(index).getDtBusinessDay()));
        
        if (businessDays.get(index).getFlagCount()!=null&&businessDays.get(index).getFlagCount().equals("N")) {
            dateLb.addStyleName("marketrisk-dateLbnontrading");
        }else{
            dateLb.addStyleName("marketrisk-dateLb");
        }
        if (setUserDefiendCalendarHighLight(businessDays.get(index).getDtBusinessDay())) {
            dateLb.removeStyleName("marketrisk-dateLb");
            dateLb.addStyleName("marketrisk-dateLbnontrading");
        }
        dateVertical.addComponent(dateLb);
        dateVertical.setComponentAlignment(dateLb, Alignment.TOP_CENTER);
        
        Label description = new Label(businessDays.get(index).getNameChange());
//        Label description = new Label("轻微跳变");
        description.addStyleName("marketrisk-description");
        dateVertical.addComponent(description);
        dateVertical.setComponentAlignment(description, Alignment.MIDDLE_CENTER);
        
        Button changeStateBtn = new Button("修改状态");
        changeStateBtn.setData(Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(index).getDtBusinessDay()));
        changeStateBtn.addStyleName("marketrisk-changestatebtn");
        buttonListener();
        changeStateBtn.addClickListener(clickListener );
        dateVertical.addComponent(changeStateBtn);
        dateVertical.setComponentAlignment(changeStateBtn, Alignment.MIDDLE_CENTER);
        
//                ReportingView bean = ComponentUtil.applicationContext.getBean(ReportingView.class);
//                bean.getHeader().getMenuBar().addComponentToTab(event.getButton().getData().toString());
//        Label blankLb = new Label();
//        blankLb.addStyleName("marketdata-blankLb");
        thumbnailHorizontalLayout.addComponent(dateVertical);

    }
    private void generateBlankLayout(HorizontalLayout thumbnailHorizontalLayout) {
        VerticalLayout dateVertical = new VerticalLayout();
        dateVertical.addStyleName("marketrisk-datevertical");
        thumbnailHorizontalLayout.addComponent(dateVertical);
    }

    private boolean setNobusinessDaysReportLayout() {
        if (businessDays == null || businessDays.size() <= 0) {
            HorizontalLayout noReportLayout = new HorizontalLayout();
            noReportLayout.setWidth("400px");
            thumbnailVertical.addComponent(noReportLayout);
            thumbnailVertical.setComponentAlignment(noReportLayout, Alignment.MIDDLE_CENTER);
            Label l = new Label("当前日期无日历");
            l.addStyleName("usermanage-l");

            noReportLayout.addComponent(l);
            noReportLayout.setComponentAlignment(l, Alignment.MIDDLE_CENTER);
            return true;
        }
        return false;
    }

    private boolean setUserDefiendCalendarHighLight(Date date) {
        if (listDate!=null&&listDate.size()>0) {
            for (int i = 0; i < listDate.size(); i++) {
                boolean equalFlag = Util.isEqualDate(listDate.get(i).getDtNonworking(), date);
                if (equalFlag) {
                    return true;
                }
            }
        }
        return false;
    }
    /**
     * Function Name : initContentTable Description : 加载日报表格数据
     * @author : Administrator
     */
    @Override
    public void initContent() {
        initDownLoadTemplate();
    }
    
    public void initDownLoadTemplate() {
        ThemeResource template=new ThemeResource("template/calendar_template.zip");
        FileDownloader fileDownLoader=new FileDownloader(template);
        fileDownLoader.extend(this.download);
    }

    private void buttonListener(){
        clickListener = new ClickListener() {
            private static final long serialVersionUID = 4178446429638195298L;

            @Override
            public void buttonClick(ClickEvent event) {
                String date = event.getButton().getData().toString();
                for (int i = 0; i < businessDays.size(); i++) {
                    if (Util.DATE_FORMATE_yyyy_MM_dd.format(businessDays.get(i).getDtBusinessDay()).equals(date)) {
                        if (businessDays.get(i).getFlagCount()!=null&&businessDays.get(i).getFlagCount().equals("N")) {
                            return;
                        }else{
                            boolean state = marketRiskCalendarProcess.selectUserOprateState(currentUser.getUserId(),date);
//                            true 代表用户未标记为非工作日;
                            if (state) {
                                marketRiskCalendarProcess.insertNonWorkingDay(((User)VaadinSession.getCurrent().getAttribute("user")).getUserId(),date);
                                //                            修改状态后变颜色
                                if (event.getButton().getParent() instanceof VerticalLayout) {
                                    VerticalLayout vertical = (VerticalLayout)event.getButton().getParent();
                                    Iterator o = vertical.iterator();
                                    while (o.hasNext()) {
                                        Component next = o.next();
                                        if (next instanceof Label&&Util.validateNumberisNaN(((Label) next).getValue())) {
                                            next.removeStyleName("marketrisk-dateLb");
                                            next.addStyleName("marketrisk-dateLbnontrading");
                                        }
                                    }
                                }
                                
                            }else{
                                boolean flag = marketRiskCalendarProcess.deleteNonWorkingDay(currentUser.getUserId(),date);
                                if (event.getButton().getParent() instanceof VerticalLayout) {
                                    VerticalLayout vertical = (VerticalLayout)event.getButton().getParent();
                                    Iterator o = vertical.iterator();
                                    while (o.hasNext()) {
                                        Component next = o.next();
                                        if (next instanceof Label&&Util.validateNumberisNaN(((Label) next).getValue())) {
                                            next.removeStyleName("marketrisk-dateLbnontrading");
                                            next.addStyleName("marketrisk-dateLb");
                                        }
                                    }
                                }
                            }
                            
                        }
                    }
                }
            }
        };
    }
    /**
     * Function Name : registerHandler Description : 查询按钮注册事件;
     * 
     * @author : Administrator
     */
    @Override
    public void registerHandler() {
        
        date.addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                initLayoutCalendar();
            }
        });
        reSizeListener = new BrowserWindowResizeListener() {
            private static final long serialVersionUID = 3770420583772426984L;

            @Override
            public void browserWindowResized(BrowserWindowResizeEvent event) {
                reSize();
            }
        };

    }
    
    private Component newLabel(String caption,String lenth,String color){
        Label lb=new Label(caption);
        lb.setWidth(lenth);
        if (color.equals("red")) {
            lb.addStyleName("red");
        }else if (color.equals("green")) {
            lb.addStyleName("green");
        }else if (color.equals("yellow")) {
            lb.addStyleName("yellow");
        }else if (color.equals("white")) {
            lb.addStyleName("marketrisk-white");
        }
        return lb;
    }
    
    private List getContinousDays(List days){
        List newlist = new ArrayList();
        if (days.size()<=0) {
        return newlist;    
        }
        String format = Util.DATE_FORMATE_yyyy_MM_dd.format(days.get(0).getDtBusinessDay());
        Date startDate = Util.getFirstDayOfMonthAsDate(format);
        Date endDate = Util.getLastDayOfMonthAsDate(format);
        int daysBetween = Util.differentDaysByMillisecond(startDate, endDate);
        for (int i = 0; i < daysBetween+1; i++) {
                if (getEqualsDate(days,startDate)!=null) {
                    newlist.add(getEqualsDate(days,startDate));
                }else{
                    BusinessDays b = new BusinessDays();
                    b.setDtBusinessDay(startDate);
                    b.setFlagCount("N");
                    newlist.add(b);
                }
                startDate = Util.increaseDate(startDate, 1);
        }
        return newlist;
    }
    
    private BusinessDays getEqualsDate(List days,Date date){
        for (BusinessDays businessDay : days) {
             Calendar cal1 = Calendar.getInstance();
                cal1.setTime(businessDay.getDtBusinessDay());

                Calendar cal2 = Calendar.getInstance();
                cal2.setTime(date);
                
            if (cal1.get(Calendar.DAY_OF_MONTH) == cal2
                    .get(Calendar.DAY_OF_MONTH)) {
                return businessDay;
            }
        }
        return null;
    }

    @Override
    public void uploadFailed(FailedEvent event) {
        Notification.show("提示:", "上传文件失败,请重新上传", Notification.Type.WARNING_MESSAGE);
    }

    @Override
    public void uploadSucceeded(SucceededEvent event) {
        if ("calendar".equals(event.getUpload().getData().toString())) {
            importFileName.setValue(fileUploaded.getName());
            
            try {
                BufferedReader buf = new BufferedReader(new InputStreamReader(new FileInputStream(fileUploaded)));
                String line = buf.readLine();
                if (line.contains(",")||line.contains(",")) {
                    Notification.show("提示:", "你上传的文件第一行有误请修改或选择合适的模板 !", Notification.Type.WARNING_MESSAGE);
                    return;
                }
                    uploadDateList(buf);  //调用方法存入数据库
                    buf.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } 
        
    }

    private void uploadDateList(BufferedReader buf) throws IOException {
        List dateList = new ArrayList();
        
        String line = null;
        try {
            while ((line = buf.readLine()) != null) {
                if(!Util.IsDate(line)){
                    Notification.show("提示:", "你上传的文件不符合模板的格式要求,请选择合适的模板 !", Notification.Type.WARNING_MESSAGE);
                    return;
                }
                dateList.add(line);
            }
            marketRiskCalendarProcess.insertNonWorkingDayByDateList(((User)VaadinSession.getCurrent().getAttribute("user")).getUserId(),dateList);
        } catch (IOException e) {
            buf.close();
            e.printStackTrace();
        }
        
    }

    @Override
    public OutputStream receiveUpload(String filename, String mimeType) {
        fileUploaded = new File(filename);
        FileOutputStream fileStream = null;
        try {
            fileStream = new FileOutputStream(fileUploaded);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
        return fileStream;
    }
}

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
2星期前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
2年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Stella981 Stella981
2年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
6个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这