| | |
| | | |
| | | |
| | | import com.nanometer.smartlab.entity.HazardousWaste; |
| | | import com.nanometer.smartlab.entity.dto.HazardousWasteUser; |
| | | import com.nanometer.smartlab.entity.enumtype.Waster; |
| | | import com.nanometer.smartlab.service.HazardousWasteService; |
| | | import com.nanometer.smartlab.util.FacesUtils; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.primefaces.model.LazyDataModel; |
| | | import org.primefaces.model.SortOrder; |
| | |
| | | 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; |
| | | import javax.faces.event.ActionListener; |
| | | import java.util.*; |
| | | |
| | | @Controller |
| | | @Scope("session") |
| | |
| | | |
| | | private Date startTime; |
| | | private Date endTime; |
| | | |
| | | private boolean isSearch; |
| | | private String status; |
| | | private String applyPerson; |
| | | private String project; |
| | | private String department; |
| | | private String tid; |
| | | private List<String> statusList = new ArrayList<> (); |
| | | private boolean isSearch = false; |
| | | private boolean isAnalysSearch = false; |
| | | private LazyDataModel<HazardousWaste> analysisDataModel; |
| | | |
| | | @Resource |
| | | private HazardousWasteService hazardousWasteService; |
| | |
| | | |
| | | 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 (getUser().getWaster() != null){ |
| | | if (getUser().getWaster().equals(Waster.MANAGE)){ |
| | | int pageCount = hazardousWasteService.countAll(startTime,endTime,status,applyPerson,project,department,tid); |
| | | this.setRowCount(pageCount); |
| | | if (pageCount > 0) |
| | | list = hazardousWasteService.selectAll(startTime,endTime,status,applyPerson,project,department,tid,first, pageSize); |
| | | }else if (StringUtils.isNotBlank(getUser().getProject())){ |
| | | int pageCount = hazardousWasteService.countAll(startTime,endTime,status,applyPerson,getUser().getProject(),department,tid); |
| | | this.setRowCount(pageCount); |
| | | if (pageCount > 0) |
| | | list = hazardousWasteService.selectAll(startTime,endTime,status,applyPerson,getUser().getProject(),department,tid,first, pageSize); |
| | | } |
| | | } |
| | | //查询更换模式 |
| | | if (isSearch) { |
| | | isSearch = false; |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | logger.error("error occured.", e); |
| | | } |
| | |
| | | this.isSearch = true; |
| | | } |
| | | |
| | | |
| | | |
| | | public void setDataModel(LazyDataModel<HazardousWaste> dataModel) { |
| | | this.dataModel = dataModel; |
| | | } |
| | | |
| | | public LazyDataModel<HazardousWaste> getAnalysisDataModel() { |
| | | if (this.analysisDataModel == null) { |
| | | this.analysisDataModel = 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.countStatistics(startTime,endTime,status,applyPerson,project,department); |
| | | |
| | | this.setRowCount(pageCount); |
| | | if (pageCount > 0) |
| | | list = hazardousWasteService.selectStatistics(startTime,endTime,status,applyPerson,project,department,first, pageSize); |
| | | |
| | | //查询更换模式 |
| | | if (isAnalysSearch) { |
| | | isAnalysSearch = 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 analysisDataModel; |
| | | } |
| | | |
| | | public void modelAnalysisChange() { |
| | | this.isAnalysSearch = true; |
| | | } |
| | | |
| | | public void setAnalysisDataModel(LazyDataModel<HazardousWaste> dataModel) { |
| | | this.analysisDataModel = dataModel; |
| | | } |
| | | |
| | | public Date getStartTime() { |
| | |
| | | public void setSearch(boolean search) { |
| | | isSearch = search; |
| | | } |
| | | |
| | | public String getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getApplyPerson() { |
| | | return applyPerson; |
| | | } |
| | | |
| | | public void setApplyPerson(String applyPerson) { |
| | | this.applyPerson = applyPerson; |
| | | } |
| | | |
| | | public String getProject() { |
| | | return project; |
| | | } |
| | | |
| | | public void setProject(String project) { |
| | | this.project = project; |
| | | } |
| | | |
| | | public String getDepartment() { |
| | | return department; |
| | | } |
| | | |
| | | public void setDepartment(String department) { |
| | | this.department = department; |
| | | } |
| | | |
| | | public List<String> getStatusList() { |
| | | statusList = new ArrayList<> (); |
| | | statusList.add("全部"); |
| | | statusList.add("待确认"); |
| | | statusList.add("已解决"); |
| | | statusList.add("已拒绝"); |
| | | return statusList; |
| | | } |
| | | |
| | | |
| | | public void export2Excel() { |
| | | List<Map> list = new ArrayList<>(); |
| | | if (getUser().getWaster() != null){ |
| | | if (getUser().getWaster().equals(Waster.MANAGE)){ |
| | | list = hazardousWasteService.exportList(startTime,endTime,status,applyPerson,project,department,tid); |
| | | }else if (StringUtils.isNotBlank(getUser().getProject())){ |
| | | list = hazardousWasteService.exportList(startTime,endTime,status,applyPerson,getUser().getProject(),department,tid); |
| | | } |
| | | } |
| | | |
| | | try{ |
| | | hazardousWasteService.export2Excel(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | FacesUtils.warn("导出失败"); |
| | | } |
| | | } |
| | | |
| | | public void exportStatistics2Excel(){ |
| | | List<Map> list = hazardousWasteService.exportStatisticsList(startTime,endTime,status,applyPerson,project,department); |
| | | try{ |
| | | hazardousWasteService.exportStatistics2Excel(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | FacesUtils.warn("导出失败"); |
| | | } |
| | | } |
| | | |
| | | public String getTid() { |
| | | return tid; |
| | | } |
| | | |
| | | public void setTid(String tid) { |
| | | this.tid = tid; |
| | | } |
| | | } |