| | |
| | | import com.nanometer.smartlab.entity.SysReagent; |
| | | import com.nanometer.smartlab.entity.SysUser; |
| | | import com.nanometer.smartlab.entity.enumtype.ApplyStatus; |
| | | import com.nanometer.smartlab.exception.BusinessException; |
| | | import com.nanometer.smartlab.service.*; |
| | | import com.nanometer.smartlab.util.Constants; |
| | | import com.nanometer.smartlab.util.FacesUtils; |
| | |
| | | import org.apache.poi.hssf.usermodel.HSSFSheet; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.primefaces.context.RequestContext; |
| | | import org.primefaces.event.FileUploadEvent; |
| | | import org.primefaces.event.SelectEvent; |
| | | import org.primefaces.event.TabChangeEvent; |
| | | import org.primefaces.model.LazyDataModel; |
| | | import org.primefaces.model.SortOrder; |
| | | import org.springframework.context.annotation.Scope; |
| | |
| | | private Timestamp endDeadline; |
| | | private Integer status; |
| | | private Integer favor; |
| | | private boolean favorFlag; |
| | | private List<ApplyStatus> statusSelectList; |
| | | |
| | | private LazyDataModel<SysReagent> reagentDataModel; |
| | | private LazyDataModel<SysReagent> reagentFavorDataModel; |
| | | private String applyNewReagentName; |
| | | private String applyNewCas; |
| | | private String applyNewSn; |
| | | private SysReagent selectReagent; |
| | | private int tabValue; |
| | | private boolean isFlush = false; |
| | | |
| | | public boolean isFavorFlag() { |
| | | return favorFlag; |
| | | } |
| | | |
| | | public void setFavorFlag(boolean favorFlag) { |
| | | this.favorFlag = favorFlag; |
| | | } |
| | | |
| | | |
| | | public SysReagent getSelectReagent() { |
| | | return selectReagent; |
| | |
| | | public void setSelectReagent(SysReagent selectReagent) { |
| | | try { |
| | | sysUserService.updateUserFavor(selectReagent, getUser()); |
| | | this.isFlush = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | FacesUtils.warn(e.getMessage()); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void uploadApply(FileUploadEvent event){ |
| | | try { |
| | | opeApplyService.importApply(event, getUser()); |
| | | FacesUtils.info("导入成功"); |
| | | } catch (BusinessException e) { |
| | | FacesUtils.warn(e.getMessage()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | FacesUtils.warn("导入失败,请联系管理员"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public HSSFWorkbook exportExcelNew(List<String> headerList, List<OpeApply> dataList) { |
| | | HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public void onTabChange(TabChangeEvent event) { |
| | | if ("reagent".equals(event.getTab().getId())) { |
| | | tabValue = 0; |
| | | if (isFlush){ |
| | | RequestContext.getCurrentInstance().execute("document.querySelector('.reagentSearch').click()"); |
| | | isFlush = false; |
| | | } |
| | | }else if ("applyHistory".equals(event.getTab().getId())){ |
| | | tabValue = 1; |
| | | }else{ |
| | | tabValue = 2; |
| | | } |
| | | } |
| | | public void onReagentNewBtnClick() { |
| | | this.sysReagent = new SysReagent(); |
| | | } |
| | |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | | selectedList = null; |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public OpeApply getRowData(String rowKey) { |
| | | Iterator<OpeApply> iterator = this.iterator(); |
| | | if (iterator != null) { |
| | | OpeApply oa = null; |
| | | while (iterator.hasNext()) { |
| | | oa = iterator.next(); |
| | | if (rowKey.equals(oa.getId())) { |
| | | return oa; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | // Iterator<OpeApply> iterator = this.iterator(); |
| | | // if (iterator != null) { |
| | | // OpeApply oa = null; |
| | | // while (iterator.hasNext()) { |
| | | // oa = iterator.next(); |
| | | // if (rowKey.equals(oa.getId())) { |
| | | // return oa; |
| | | // } |
| | | // } |
| | | // } |
| | | return opeApplyService.getOpeApply(rowKey); |
| | | } |
| | | }; |
| | | } |
| | |
| | | public List<SysReagent> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) { |
| | | List<SysReagent> list = null; |
| | | try { |
| | | int count = sysReagentService.getSysReagentTotalCount2(getUser(),favorFlag ? 1 :null,applyNewReagentName, applyNewCas, applyNewSn,null); |
| | | int count = sysReagentService.reagentCount(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn); |
| | | this.setRowCount(count); |
| | | if (count > 0) { |
| | | list = sysReagentService.getSysReagentList2(getUser(),favorFlag ? 1 : null,applyNewReagentName, applyNewCas, applyNewSn,null, first, pageSize); |
| | | list = sysReagentService.reagentList(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn, first, pageSize,count); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | |
| | | |
| | | @Override |
| | | public SysReagent getRowData(String rowKey) { |
| | | Iterator<SysReagent> iterator = this.iterator(); |
| | | if (iterator != null) { |
| | | SysReagent sr = null; |
| | | while (iterator.hasNext()) { |
| | | sr = iterator.next(); |
| | | if (rowKey.equals(sr.getId())) { |
| | | return sr; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | // Iterator<SysReagent> iterator = this.iterator(); |
| | | // if (iterator != null) { |
| | | // SysReagent sr = null; |
| | | // while (iterator.hasNext()) { |
| | | // sr = iterator.next(); |
| | | // if (rowKey.equals(sr.getId())) { |
| | | // return sr; |
| | | // } |
| | | // } |
| | | // } |
| | | return sysReagentService.getRowData(rowKey); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | return reagentDataModel; |
| | | } |
| | | |
| | | |
| | | public LazyDataModel<SysReagent> getReagentFavorDataModel() { |
| | | if (this.reagentFavorDataModel == null) { |
| | | this.reagentFavorDataModel = new LazyDataModel<SysReagent>() { |
| | | @Override |
| | | public List<SysReagent> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) { |
| | | List<SysReagent> list = null; |
| | | try { |
| | | int count = sysReagentService.favorCount(getUser(), null, null, null,null,1); |
| | | this.setRowCount(count); |
| | | if (count > 0) { |
| | | list = sysReagentService.favorList(getUser(),null, null,null, null,1, first, pageSize); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public SysReagent getRowData(String rowKey) { |
| | | // Iterator<SysReagent> iterator = this.iterator(); |
| | | // if (iterator != null) { |
| | | // SysReagent sr = null; |
| | | // while (iterator.hasNext()) { |
| | | // sr = iterator.next(); |
| | | // if (rowKey.equals(sr.getId())) { |
| | | // return sr; |
| | | // } |
| | | // } |
| | | // } |
| | | return sysReagentService.getRowData(rowKey); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | return reagentFavorDataModel; |
| | | } |
| | | |
| | | public LazyDataModel<OpeApply> getApplyHistoryDataModel() { |
| | |
| | | if (count > 0) { |
| | | list = opeApplyService.getOpeApplyList(null, null, null, null, applyUserId, null, null, first, pageSize,applyCode,null); |
| | | } |
| | | selectedList = null; |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public OpeApply getRowData(String rowKey) { |
| | | Iterator<OpeApply> iterator = this.iterator(); |
| | | if (iterator != null) { |
| | | OpeApply oa = null; |
| | | while (iterator.hasNext()) { |
| | | oa = iterator.next(); |
| | | if (rowKey.equals(oa.getId())) { |
| | | return oa; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | // Iterator<OpeApply> iterator = this.iterator(); |
| | | // if (iterator != null) { |
| | | // OpeApply oa = null; |
| | | // while (iterator.hasNext()) { |
| | | // oa = iterator.next(); |
| | | // if (rowKey.equals(oa.getId())) { |
| | | // return oa; |
| | | // } |
| | | // } |
| | | // } |
| | | return opeApplyService.getOpeApply(rowKey); |
| | | } |
| | | }; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public Integer getFavor() { |
| | | return favor; |
| | | public int getTabValue() { |
| | | return tabValue; |
| | | } |
| | | |
| | | public void setFavor(Integer favor) { |
| | | this.favor = favor; |
| | | public void setTabValue(int tabValue) { |
| | | this.tabValue = tabValue; |
| | | } |
| | | } |