对比新文件 |
| | |
| | | package com.nanometer.smartlab.controller; |
| | | |
| | | |
| | | import com.nanometer.smartlab.entity.HazardousWaste; |
| | | import com.nanometer.smartlab.service.HazardousWasteService; |
| | | import org.apache.log4j.Logger; |
| | | import org.primefaces.model.LazyDataModel; |
| | | import org.primefaces.model.SortOrder; |
| | | import org.springframework.context.annotation.Scope; |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Controller |
| | | @Scope("session") |
| | | public class HazardousWasteController extends BaseController{ |
| | | |
| | | private static Logger logger = Logger.getLogger(HazardousWasteController.class); |
| | | |
| | | private LazyDataModel<HazardousWaste> dataModel; |
| | | |
| | | private Date startTime; |
| | | private Date endTime; |
| | | |
| | | private boolean isSearch; |
| | | |
| | | @Resource |
| | | private HazardousWasteService hazardousWasteService; |
| | | |
| | | public LazyDataModel<HazardousWaste> getDataModel() { |
| | | if (this.dataModel == null) { |
| | | this.dataModel = new LazyDataModel<HazardousWaste>() { |
| | | |
| | | public List<HazardousWaste> load |
| | | (int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) { |
| | | |
| | | List<HazardousWaste> list = null; |
| | | try { |
| | | int pageCount = hazardousWasteService.countAll(startTime,endTime); |
| | | |
| | | this.setRowCount(pageCount); |
| | | if (pageCount > 0) |
| | | list = hazardousWasteService.selectAll(startTime,endTime, isSearch ? 0 : first, pageSize); |
| | | //查询更换模式 |
| | | if (isSearch) { |
| | | isSearch = false; |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | logger.error("error occured.", e); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public HazardousWaste getRowData(String rowKey) { |
| | | Iterator<HazardousWaste> iterator = this.iterator(); |
| | | HazardousWaste su = null; |
| | | while (iterator.hasNext()) { |
| | | su = iterator.next(); |
| | | if ( su.getId().equals(Long.parseLong(rowKey))) { |
| | | return su; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | }; |
| | | } |
| | | return dataModel; |
| | | } |
| | | |
| | | public void modelChange() { |
| | | this.isSearch = true; |
| | | } |
| | | |
| | | |
| | | |
| | | public void setDataModel(LazyDataModel<HazardousWaste> dataModel) { |
| | | this.dataModel = dataModel; |
| | | } |
| | | |
| | | public Date getStartTime() { |
| | | return startTime; |
| | | } |
| | | |
| | | public void setStartTime(Date startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public Date getEndTime() { |
| | | return endTime; |
| | | } |
| | | |
| | | public void setEndTime(Date endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | public boolean isSearch() { |
| | | return isSearch; |
| | | } |
| | | |
| | | public void setSearch(boolean search) { |
| | | isSearch = search; |
| | | } |
| | | } |