后端Springboot前端VUE实现Excel导入功能

China☆狼群 提交于 2020-01-20 17:45:06
功能描述:做的是物联网的项目,Excel导入实现的功能是将Excel中的数据批量的导入AEP系统,再导入我们系统中。目前已经完成该功能,前端还会添加进度条优化。Excel模板:

 

 

前端向后端传递的参数:

 

 

前端代码:
<Upload  name="wlwDeviceFile"  ref="upload"  :action="pathUrl"  :on-success="handleSuccess"  :on-error="handleError"  :format="['xls','xlsx']"  :max-size="5120"  :on-format-error="handleFormatError"  :on-exceeded-size="handleMaxSize"  :before-upload="handleBeforeUpload"  :data="extraData"  :disabled="!isLock">  <Button type="primary">选择文件</Button></Upload>
data() {  return {    isLock: true,    mesg: false,    extraData: {      aepProductId: localStorage.productId,      productId: localStorage.productItemId,      projectId: localStorage.currentProjectId    },    mes: "",    cod: 0,    // currentShow: false,    pathUrl: Util.baseUrl + "/api/excel/import",    wlwDevice: {      fileName: "", //用于显示上传文件名      id: localStorage.productId,      autoSubscribe: 0    },    ruleValidate: {      fileName: [        {          required: true,          message: "请选择文件",          trigger: "change"        }      ]    }  };},

handleSuccess(res, file) {  // console.log("res++++++++++++++++++++++++++", res);  if (res.code == 0) {    this.cod = res.code;    this.mes = '导入成功';    console.log(this.$refs.upload.fileList);    // this.$refs.upload.fileList.splice(0, 1);  } else {    this.cod = res.code;    this.mes = res.message;  }  this.isLock = true;  // this.$Spin.hide();  this.wlwDevice.fileName = file.name;  if (this.$refs.upload.fileList.length > 1) {    this.$refs.upload.fileList.splice(0, 1);  }  // this.$emit("cancel", this.isOpen);},
handleSubmit(name) {  console.log("----------------------");  this.$refs[name].validate(valid => {    if (valid) {      this.mesg = true;      this.$refs[name].resetFields();      this.$emit("cancel", this.isOpen);      this.$emit("refreshList");      console.log("-------------@@@--------");    } else {      this.$Message.error(this.$t("errorText"));    }  });},
后端解析 Excel,将数据读取出来导入AEP系统

 

 导入我们系统:

 

 

后端代码:导入POM依赖:<dependency>
    <groupId>org.apache.poi</groupId>    <artifactId>poi-ooxml</artifactId>    <version>3.9</version></dependency><dependency>    <groupId>org.apache.poi</groupId>    <artifactId>poi-ooxml-schemas</artifactId>    <version>3.9</version></dependency>
解析Excel的方法:
@Component@NoArgsConstructorpublic class ParseExcelUtil {    private static final Logger log = LoggerFactory.getLogger(ParseExcelUtil.class);    public static Workbook getWorkbook(InputStream is, String fileName) throws ExcelIOException {        Workbook workbook = null;        String fileType = fileName.substring(fileName.lastIndexOf("."));        // 推荐使用poi-ooxml中的WorkbookFactory.create(is)来创建Workbook,        // 因为HSSFWorkbook和XSSFWorkbook都实现了Workbook接口(可以解决以下报错问题)        try {            if (ExcelVersion.V2003.getSuffix().equals(fileType)) {                workbook = new HSSFWorkbook(is);            } else if (ExcelVersion.V2007.getSuffix().equals(fileType)) {                workbook = new XSSFWorkbook(is);            }        }catch (IOException e){            // 无效后缀名称,这里之能保证excel的后缀名称,不能保证文件类型正确,不过没关系,在创建Workbook的时候会校验文件格式            throw new ExcelIOException("请上传文件!");        }        return workbook;    }}
Excel版本问题的枚举:
@NoArgsConstructorpublic enum ExcelVersion {        /**         * 虽然V2007版本支持最大支持1048575 * 16383 ,         * V2003版支持65535*255         * 但是在实际应用中如果使用如此庞大的对象集合会导致内存溢出,         * 因此这里限制最大为10000*100,如果还要加大建议先通过单元测试进行性能测试。         * 1000*100 全部导出预计时间为27s左右         */        V2003(".xls", 10000, 100), V2007(".xlsx", 100, 100);        private String suffix;        private int maxRow;        private int maxColumn;        ExcelVersion(String suffix, int maxRow, int maxColumn) {            this.suffix = suffix;            this.maxRow = maxRow;            this.maxColumn = maxColumn;        }        public String getSuffix() {            return this.suffix;        }        public int getMaxRow() {            return maxRow;        }        void setMaxRow(int maxRow) {            this.maxRow = maxRow;        }        public int getMaxColumn() {            return maxColumn;        }        void setMaxColumn(int maxColumn) {            this.maxColumn = maxColumn;        }        void setSuffix(String suffix) {            this.suffix = suffix;        }}
Long型转ZonedDateTime型方法:
/** * 将Long类型转化成0 * @author yk * @param time * @return */public static ZonedDateTime toZonedDateTime(Long time){    SimpleDateFormat sdf = new SimpleDateFormat(LONG_DATE);    Date createDate = new Date(time);    String format = sdf.format(createDate);    DateTimeFormatter beijingFormatter = DateTimeFormatter.ofPattern(LONG_DATE).withZone(ZoneId.of("Asia/Shanghai"));    if(StringUtils.isBlank(format)){        return null;    }    ZonedDateTime beijingDateTime = ZonedDateTime.parse(format, beijingFormatter);    ZonedDateTime utc = beijingDateTime.withZoneSameInstant(ZoneId.of("UTC"));    return utc;}
控制层@RestController@RequestMapping("/api/excel")public class ImportExcelController {    private final Logger log = LoggerFactory.getLogger(ImportExcelController.class);    private final WlwDeviceService wlwDeviceService;    @Autowired    private ImportExcelService importExcelService;    public ImportExcelController(WlwDeviceService wlwDeviceService) {        this.wlwDeviceService = wlwDeviceService;    }    @PostMapping("/import")    public ImportExcelResult excelToWlwDevice(@RequestParam("wlwDeviceFile") MultipartFile wlwDeviceFile, @RequestParam("productId") String productId, @RequestParam("aepProductId") String aepProductId, @RequestParam("projectId") String projectId) throws Exception {        return importExcelService.excelToWlwDeviceService(wlwDeviceFile, productId, aepProductId, projectId);    }Service接口:
public interface ImportExcelService {    /**     * 导入     * @param wlwDeviceFile     * @param productId     * @param aepProductId     * @param projectId     * @return     */    ImportExcelResult excelToWlwDeviceService(MultipartFile wlwDeviceFile, String productId, String aepProductId, String projectId);}Service实现类:
@Servicepublic class ImportExcelServiceImpl implements ImportExcelService {    private static final Logger log = LoggerFactory.getLogger(ImportExcelServiceImpl.class);    @Autowired    private AepApiUtil util;    @Autowired    private WlwDeviceRepository wlwDeviceRepository;    @Override    public ImportExcelResult excelToWlwDeviceService(MultipartFile wlwDeviceFile, String productId, String aepProductId, String projectId) {        ImportExcelResult importExcelResult = new ImportExcelResult(0, "导入成功");        //List<String> sList = new ArrayList<>();        if (wlwDeviceFile.isEmpty()) {            importExcelResult.setCode(100);            importExcelResult.setMessage("填写模版信息不能为空");            return importExcelResult;        }        //1.将excel中的数据放入list中        List<AepDeviceDTO> aepDeviceDTOList = new ArrayList<>();        //解析Excel文件        try {            InputStream is = wlwDeviceFile.getInputStream();            int size = 0;            String imei = null;            //厂家名称            String manufacturer = null;            //型号            String productType = null;            //设备名称            String deviceName = null;            //自动订阅            String autoObserver = null;            //设备类型            String deviceType = null;            StringBuilder megBuilder = new StringBuilder();            String filename = wlwDeviceFile.getOriginalFilename();            //1.根据Excel文件创建工作簿            Workbook wb = ParseExcelUtil.getWorkbook(is, filename);            //2.获取Sheet            Sheet sheet = wb.getSheetAt(0);            if (sheet != null) {                WlwDevice wlwDevice = new WlwDevice();                //3.获取Sheet中的每一行,和每一个单元格,数据从第二行开始                for (int rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) {                    log.info("处理到{}条记录",rowNum);                    //根据索引获取每一个行                    Row row = sheet.getRow(rowNum);                    size = row.getLastCellNum();                    //Aep的设备实体类                    AepDeviceDTO deviceDTO = new AepDeviceDTO();                    AepDeviceOther other = new AepDeviceOther();                    Set<String> imeiMap = new HashSet<>();                    for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++) {                        Cell cell = row.getCell(cellNum);                        if (null == cell) {                            break;                        }                        //根据索引获取每一个单元格  获取每一个单元格的内容;                        switch (cellNum) {                            case 0:                                manufacturer = cell.getStringCellValue();                                break;                            case 1:                                productType = cell.getStringCellValue();                                break;                            case 2:                                imei = cell.getStringCellValue();                                if (StringUtils.isBlank(imei)) {                                    importExcelResult.setCode(101);                                    megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[").append(deviceName).append("],失败原因:IMEI号不能为空");                                    continue;                                }                                if (imei.trim().length() != 15) {                                    importExcelResult.setCode(102);                                    megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[").append(deviceName).append("],失败原因:IMEI号必须是15位");                                    continue;                                }                                deviceDTO.setImei(imei.trim());                                wlwDevice.setImei(imei.trim());                                break;                            case 3:                                deviceName = cell.getStringCellValue();                                if (StringUtils.isBlank(deviceName)) {                                    importExcelResult.setCode(104);                                    megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[").append(deviceName).append("],失败原因:设备名称不能为空");                                    continue;                                }                                deviceDTO.setDeviceName(deviceName.trim());                                wlwDevice.setDeviceName(deviceName.trim());                                break;                            case 4:                                autoObserver = cell.getStringCellValue();                                if (StringUtils.isBlank(autoObserver)) {                                    importExcelResult.setCode(105);                                    megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[").append(deviceName).append("],失败原因:设备必须选择是否自动订阅");                                    continue;                                }                                //Aep的设备实体类的autoObserver    pass平台暂时不做自动订阅和PSK,若做在这里set                                if (autoObserver.trim().hashCode() == 26159) {                                    other.setAutoObserver(0);                                } else if (autoObserver.trim().hashCode() == 21542) {                                    other.setAutoObserver(1);                                } else {                                    importExcelResult.setCode(106);                                    megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[").append(deviceName).append("],失败原因:设备必须选择是否自动订阅");                                    continue;                                }                                break;                            case 5:                                deviceName = cell.getStringCellValue();                                break;                            default:                                break;                        }                    }                    deviceDTO.setProductId(Long.valueOf(aepProductId));                    deviceDTO.setOther(other);                    deviceDTO.setOperator(String.valueOf(SecurityUtils.getCurrentUserId()));                    aepDeviceDTOList.add(deviceDTO);                    //2.遍历list校验是否有重复的imei号                    boolean add = imeiMap.add(imei);                    if (!add) {                        importExcelResult.setCode(108);                        megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[")                                .append(deviceName).append("],失败原因:设备IMEI存在重复数据,请检查模板");                        continue;                    }                    //导入aep系统的设备                    AepCreateDeviceResponse aepDevice = util.createAepDevice(deviceDTO);                    Thread.sleep(200);                    System.out.println("调用aep接口:" + aepDevice.getResult());                    if (aepDevice.getCode() != 0) {                        importExcelResult.setCode(aepDevice.getCode());                        megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[")                                .append(deviceName).append("],失败原因:").append(aepDevice.getMsg());                        continue;                    } else {                        importExcelResult.setCode(0);                        importExcelResult.setMessage(aepDevice.getMsg());                        //aep返回的结果参数                        AepDevice result = aepDevice.getResult();                        wlwDevice.setDeviceId(result.getDeviceId());                        wlwDevice.setProductId(Long.valueOf(productId));                        wlwDevice.setProjectId(Integer.valueOf(projectId));                        wlwDevice.setAepProductId(Long.valueOf(result.getProductId()));                        wlwDevice.setDeviceSn(result.getDeviceSn());                        wlwDevice.setTenantId(result.getTenantId());                        wlwDevice.setUpdatedDate(result.getUpdateTime() == null ? null : DateUtils.toZonedDateTime(result.getUpdateTime()));                        wlwDevice.setNetStatus(result.getNetStatus());                        wlwDevice.setUpdaterId(result.getOperator());                        int insert = wlwDeviceRepository.insert(wlwDevice);                        if (insert == 0) {                            importExcelResult.setCode(109);                            megBuilder.append("行号=[").append (rowNum + 1).append("];IMEI=[").append(imei).append("],设备名称=[").append(deviceName).append("],失败原因:PasS系统导入错误").append(aepDevice.getResult().getDeviceName());                            continue;                        }                    }                }            }            importExcelResult.setMessage(megBuilder.toString());            is.close();        } catch (Exception e) {            log.error("插入设备失败", e);            importExcelResult.setCode(-1);            importExcelResult.setMessage("插入设备失败");        }        return importExcelResult;    }}  AepDeviceDTO实体类:
public class AepDeviceDTO {    /**     * 终端名称     */    private String deviceName;    /**     * 设备编号     */    private String deviceSn;    /**     * IMEI号,全局唯一,根据产品的Endpoint必填,创建时可相同,则删除原产品新建产品     */    private String imei;    /**     * 操作者     */    private String operator;    /**     * LWM2M协议必填参数,其他协议不填     *  {     *    autoObserver:0.自动订阅 1.取消自动订阅,必填;     *    imsi:总长度不超过15位,使用0~9的数字,String类型,选填;     *    pskValue:由大小写字母加0-9数字组成的16位字符串,选填     *  }     */    private AepDeviceOther other;    /**     * 产品id     */    private Long productId;    public String getDeviceName() {        return deviceName;    }    public void setDeviceName(String deviceName) {        this.deviceName = deviceName;    }    public String getDeviceSn() {        return deviceSn;    }    public void setDeviceSn(String deviceSn) {        this.deviceSn = deviceSn;    }    public String getImei() {        return imei;    }    public void setImei(String imei) {        this.imei = imei;    }    public String getOperator() {        return operator;    }    public void setOperator(String operator) {        this.operator = operator;    }    public AepDeviceOther getOther() {        return other;    }    public void setOther(AepDeviceOther other) {        this.other = other;    }    public Long getProductId() {        return productId;    }    public void setProductId(Long productId) {        this.productId = productId;    }    @Override    public String toString() {        return "AepDeviceDTO{" +                "deviceName='" + deviceName + '\'' +                ", deviceSn='" + deviceSn + '\'' +                ", imei='" + imei + '\'' +                ", operator='" + operator + '\'' +                ", other=" + other +                ", productId=" + productId +                '}';    }}  AepDeviceOther实体类:
public class AepDeviceOther {    /**     * 0.自动订阅 1.取消自动订阅,必填;     */    private Integer autoObserver;    /**     * 总长度不超过15位,使用0~9的数字,String类型,选填;     */    private String imsi;    /**     * 由大小写字母加0-9数字组成的16位字符串,选填     */    private String pskValue;    public Integer getAutoObserver() {        return autoObserver;    }    public void setAutoObserver(Integer autoObserver) {        this.autoObserver = autoObserver;    }    public String getImsi() {        return imsi;    }    public void setImsi(String imsi) {        this.imsi = imsi;    }    public String getPskValue() {        return pskValue;    }    public void setPskValue(String pskValue) {        this.pskValue = pskValue;    }    @Override    public String toString() {        return "{" +                "autoObserver=" + autoObserver +                ", imsi='" + imsi + '\'' +                ", pskValue='" + pskValue + '\'' +                '}';    }}WlwDevice实体类:
public class WlwDevice implements Serializable {    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private Integer id;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.create_date     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private ZonedDateTime createDate;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.updated_date     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private ZonedDateTime updatedDate;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.del_flag     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private Integer delFlag;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.creator_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String creatorId;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.updater_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String updaterId;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.device_name     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String deviceName;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.device_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String deviceId;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.device_sn     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String deviceSn;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.imei     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String imei;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.imsi     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String imsi;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.product_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private Long productId;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.aep_product_id     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    private Long aepProductId;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.project_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private Integer projectId;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.remark     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String remark;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.last_up_time     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private ZonedDateTime lastUpTime;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.last_down_time     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private ZonedDateTime lastDownTime;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.device_status     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    private String deviceStatus;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.net_status     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    private Integer netStatus;    /**     *     * This field was generated by MyBatis Generator.     * This field corresponds to the database column wlw_device.tenant_id     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    private String tenantId;    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.id     *     * @return the value of wlw_device.id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public Integer getId() {        return id;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.id     *     * @param id the value for wlw_device.id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setId(Integer id) {        this.id = id;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.create_date     *     * @return the value of wlw_device.create_date     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public ZonedDateTime getCreateDate() {        return createDate;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.create_date     *     * @param createDate the value for wlw_device.create_date     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setCreateDate(ZonedDateTime createDate) {        this.createDate = createDate;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.updated_date     *     * @return the value of wlw_device.updated_date     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public ZonedDateTime getUpdatedDate() {        return updatedDate;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.updated_date     *     * @param updatedDate the value for wlw_device.updated_date     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setUpdatedDate(ZonedDateTime updatedDate) {        this.updatedDate = updatedDate;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.del_flag     *     * @return the value of wlw_device.del_flag     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public Integer getDelFlag() {        return delFlag;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.del_flag     *     * @param delFlag the value for wlw_device.del_flag     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setDelFlag(Integer delFlag) {        this.delFlag = delFlag;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.creator_id     *     * @return the value of wlw_device.creator_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getCreatorId() {        return creatorId;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.creator_id     *     * @param creatorId the value for wlw_device.creator_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setCreatorId(String creatorId) {        this.creatorId = creatorId == null ? null : creatorId.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.updater_id     *     * @return the value of wlw_device.updater_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getUpdaterId() {        return updaterId;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.updater_id     *     * @param updaterId the value for wlw_device.updater_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setUpdaterId(String updaterId) {        this.updaterId = updaterId == null ? null : updaterId.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.device_name     *     * @return the value of wlw_device.device_name     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getDeviceName() {        return deviceName;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.device_name     *     * @param deviceName the value for wlw_device.device_name     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setDeviceName(String deviceName) {        this.deviceName = deviceName == null ? null : deviceName.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.device_id     *     * @return the value of wlw_device.device_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getDeviceId() {        return deviceId;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.device_id     *     * @param deviceId the value for wlw_device.device_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setDeviceId(String deviceId) {        this.deviceId = deviceId == null ? null : deviceId.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.device_sn     *     * @return the value of wlw_device.device_sn     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getDeviceSn() {        return deviceSn;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.device_sn     *     * @param deviceSn the value for wlw_device.device_sn     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setDeviceSn(String deviceSn) {        this.deviceSn = deviceSn == null ? null : deviceSn.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.imei     *     * @return the value of wlw_device.imei     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getImei() {        return imei;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.imei     *     * @param imei the value for wlw_device.imei     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setImei(String imei) {        this.imei = imei == null ? null : imei.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.imsi     *     * @return the value of wlw_device.imsi     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getImsi() {        return imsi;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.imsi     *     * @param imsi the value for wlw_device.imsi     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setImsi(String imsi) {        this.imsi = imsi == null ? null : imsi.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.product_id     *     * @return the value of wlw_device.product_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public Long getProductId() {        return productId;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.product_id     *     * @param productId the value for wlw_device.product_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setProductId(Long productId) {        this.productId = productId;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.aep_product_id     *     * @return the value of wlw_device.aep_product_id     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    public Long getAepProductId() {        return aepProductId;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.aep_product_id     *     * @param aepProductId the value for wlw_device.aep_product_id     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    public void setAepProductId(Long aepProductId) {        this.aepProductId = aepProductId;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.project_id     *     * @return the value of wlw_device.project_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public Integer getProjectId() {        return projectId;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.project_id     *     * @param projectId the value for wlw_device.project_id     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setProjectId(Integer projectId) {        this.projectId = projectId;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.remark     *     * @return the value of wlw_device.remark     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getRemark() {        return remark;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.remark     *     * @param remark the value for wlw_device.remark     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setRemark(String remark) {        this.remark = remark == null ? null : remark.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.last_up_time     *     * @return the value of wlw_device.last_up_time     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public ZonedDateTime getLastUpTime() {        return lastUpTime;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.last_up_time     *     * @param lastUpTime the value for wlw_device.last_up_time     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setLastUpTime(ZonedDateTime lastUpTime) {        this.lastUpTime = lastUpTime;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.last_down_time     *     * @return the value of wlw_device.last_down_time     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public ZonedDateTime getLastDownTime() {        return lastDownTime;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.last_down_time     *     * @param lastDownTime the value for wlw_device.last_down_time     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setLastDownTime(ZonedDateTime lastDownTime) {        this.lastDownTime = lastDownTime;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.device_status     *     * @return the value of wlw_device.device_status     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public String getDeviceStatus() {        return deviceStatus;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.device_status     *     * @param deviceStatus the value for wlw_device.device_status     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    public void setDeviceStatus(String deviceStatus) {        this.deviceStatus = deviceStatus == null ? null : deviceStatus.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.net_status     *     * @return the value of wlw_device.net_status     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    public Integer getNetStatus() {        return netStatus;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.net_status     *     * @param netStatus the value for wlw_device.net_status     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    public void setNetStatus(Integer netStatus) {        this.netStatus = netStatus;    }    /**     * This method was generated by MyBatis Generator.     * This method returns the value of the database column wlw_device.tenant_id     *     * @return the value of wlw_device.tenant_id     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    public String getTenantId() {        return tenantId;    }    /**     * This method was generated by MyBatis Generator.     * This method sets the value of the database column wlw_device.tenant_id     *     * @param tenantId the value for wlw_device.tenant_id     *     * @mbg.generated Mon Dec 23 14:04:02 CST 2019     */    public void setTenantId(String tenantId) {        this.tenantId = tenantId == null ? null : tenantId.trim();    }    /**     * This method was generated by MyBatis Generator.     * This method corresponds to the database table wlw_device     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    @Override    public boolean equals(Object that) {        if (this == that) {            return true;        }        if (that == null) {            return false;        }        if (getClass() != that.getClass()) {            return false;        }        WlwDevice other = (WlwDevice) that;        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))            && (this.getCreateDate() == null ? other.getCreateDate() == null : this.getCreateDate().equals(other.getCreateDate()))            && (this.getUpdatedDate() == null ? other.getUpdatedDate() == null : this.getUpdatedDate().equals(other.getUpdatedDate()))            && (this.getDelFlag() == null ? other.getDelFlag() == null : this.getDelFlag().equals(other.getDelFlag()))            && (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))            && (this.getUpdaterId() == null ? other.getUpdaterId() == null : this.getUpdaterId().equals(other.getUpdaterId()))            && (this.getDeviceName() == null ? other.getDeviceName() == null : this.getDeviceName().equals(other.getDeviceName()))            && (this.getDeviceId() == null ? other.getDeviceId() == null : this.getDeviceId().equals(other.getDeviceId()))            && (this.getDeviceSn() == null ? other.getDeviceSn() == null : this.getDeviceSn().equals(other.getDeviceSn()))            && (this.getImei() == null ? other.getImei() == null : this.getImei().equals(other.getImei()))            && (this.getImsi() == null ? other.getImsi() == null : this.getImsi().equals(other.getImsi()))            && (this.getProductId() == null ? other.getProductId() == null : this.getProductId().equals(other.getProductId()))            && (this.getAepProductId() == null ? other.getAepProductId() == null : this.getAepProductId().equals(other.getAepProductId()))            && (this.getProjectId() == null ? other.getProjectId() == null : this.getProjectId().equals(other.getProjectId()))            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))            && (this.getLastUpTime() == null ? other.getLastUpTime() == null : this.getLastUpTime().equals(other.getLastUpTime()))            && (this.getLastDownTime() == null ? other.getLastDownTime() == null : this.getLastDownTime().equals(other.getLastDownTime()))            && (this.getDeviceStatus() == null ? other.getDeviceStatus() == null : this.getDeviceStatus().equals(other.getDeviceStatus()))            && (this.getNetStatus() == null ? other.getNetStatus() == null : this.getNetStatus().equals(other.getNetStatus()))            && (this.getTenantId() == null ? other.getTenantId() == null : this.getTenantId().equals(other.getTenantId()));    }    /**     * This method was generated by MyBatis Generator.     * This method corresponds to the database table wlw_device     *     * @mbg.generated Mon Dec 09 14:33:32 CST 2019     */    @Override    public int hashCode() {        final int prime = 31;        int result = 1;        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());        result = prime * result + ((getCreateDate() == null) ? 0 : getCreateDate().hashCode());        result = prime * result + ((getUpdatedDate() == null) ? 0 : getUpdatedDate().hashCode());        result = prime * result + ((getDelFlag() == null) ? 0 : getDelFlag().hashCode());        result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());        result = prime * result + ((getUpdaterId() == null) ? 0 : getUpdaterId().hashCode());        result = prime * result + ((getDeviceName() == null) ? 0 : getDeviceName().hashCode());        result = prime * result + ((getDeviceId() == null) ? 0 : getDeviceId().hashCode());        result = prime * result + ((getDeviceSn() == null) ? 0 : getDeviceSn().hashCode());        result = prime * result + ((getImei() == null) ? 0 : getImei().hashCode());        result = prime * result + ((getImsi() == null) ? 0 : getImsi().hashCode());        result = prime * result + ((getProductId() == null) ? 0 : getProductId().hashCode());        result = prime * result + ((getAepProductId() == null) ? 0 : getAepProductId().hashCode());        result = prime * result + ((getProjectId() == null) ? 0 : getProjectId().hashCode());        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());        result = prime * result + ((getLastUpTime() == null) ? 0 : getLastUpTime().hashCode());        result = prime * result + ((getLastDownTime() == null) ? 0 : getLastDownTime().hashCode());        result = prime * result + ((getDeviceStatus() == null) ? 0 : getDeviceStatus().hashCode());        result = prime * result + ((getNetStatus() == null) ? 0 : getNetStatus().hashCode());        result = prime * result + ((getTenantId() == null) ? 0 : getTenantId().hashCode());        return result;    }

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!