| | |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.nanometer.smartlab.entity.BaseMeta; |
| | | import com.nanometer.smartlab.entity.SysProject; |
| | | import com.nanometer.smartlab.entity.SysReagent; |
| | | import com.nanometer.smartlab.service.BaseMetaService; |
| | | import com.nanometer.smartlab.service.SysLaboratoryContainerService; |
| | | import com.nanometer.smartlab.service.SysProjectService; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | |
| | | @Resource |
| | | private SysLaboratoryService sysLaboratoryService; |
| | | @Resource |
| | | private SysLaboratoryContainerService sysLaboratoryContainerService; |
| | | @Resource |
| | | private BaseMetaService baseMetaService; |
| | | @Resource |
| | | private SysProjectService sysProjectService; |
| | |
| | | /** |
| | | * 数据模型 |
| | | */ |
| | | private SysLaboratory sysLaboratory; |
| | | private SysLaboratory sysLaboratory=new SysLaboratory(); |
| | | /** |
| | | * 选中的list |
| | | */ |
| | |
| | | RequestContext.getCurrentInstance().execute("PF('dialog').show()"); |
| | | } |
| | | |
| | | public String getProjectName(String project){ |
| | | if(StringUtils.isBlank(project)){ |
| | | return ""; |
| | | } |
| | | List<String> idstrs = Arrays.asList(project.split(",")); |
| | | List<Long> ids=idstrs.stream().map(item -> Long.valueOf(item)).collect(Collectors.toList()); |
| | | List<SysProject> projects=this.sysProjectService.getProjectByIds(ids); |
| | | if(projects==null||projects.size()==0){ |
| | | return ""; |
| | | } |
| | | List<String> projectNames=projects.stream().map(SysProject::getProjectName).collect(Collectors.toList()); |
| | | return String.join(",",projectNames); |
| | | } |
| | | public void exportLab2Excel(){ |
| | | try { |
| | | List<Map> list = sysLaboratoryService.exportLabList(type, name,project); |
| | | List<SysLaboratory> list = sysLaboratoryService.exportLabList(type, name,project); |
| | | sysLaboratoryService.exportLab2Excel(list); |
| | | FacesUtils.info("导出成功"); |
| | | }catch (Exception e){ |
| | |
| | | } |
| | | |
| | | public void uploadFile(FileUploadEvent event) { |
| | | System.out.println("=========导入开始====="); |
| | | List<BaseMeta> typeList=baseMetaService.getBaseMetaList("laboratory_type"); |
| | | List<BaseMeta> departList=baseMetaService.getBaseMetaList("user_department"); |
| | | try{ |
| | |
| | | if (valuesList.size() != 8){ |
| | | break; |
| | | } |
| | | System.out.println("value : "+valuesList); |
| | | SysLaboratory laboratory=new SysLaboratory(); |
| | | laboratory.setType(returnTypeId(typeList,valuesList.get(0))); |
| | | laboratory.setName(valuesList.get(1)); |
| | |
| | | sysLaboratories.add(laboratory); |
| | | } |
| | | sysLaboratoryService.insertSysReagentList(sysLaboratories); |
| | | System.out.println("=========导入结束====="); |
| | | FacesUtils.info("导入成功。"); |
| | | }catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | public String returnTypeId(List<BaseMeta> list,String name){ |
| | | String id=""; |
| | | public Long returnTypeId(List<BaseMeta> list,String name){ |
| | | Long id=null; |
| | | for(int i=0;i<list.size();i++){ |
| | | if(name.equals(list.get(i).getMetaValue())){ |
| | | id=list.get(i).getId(); |
| | |
| | | return id; |
| | | } |
| | | |
| | | public String returnDepartId(List<BaseMeta> list,String name){ |
| | | String id=""; |
| | | public Long returnDepartId(List<BaseMeta> list,String name){ |
| | | Long id=null; |
| | | for(int i=0;i<list.size();i++){ |
| | | if(name.equals(list.get(i).getMetaValue())){ |
| | | id=list.get(i).getId(); |
| | |
| | | } |
| | | |
| | | //实体类重新获取项目组信息 |
| | | sysLaboratory.setProject(null); |
| | | sysLaboratory.getProject(); |
| | | // sysLaboratory.setProject(null); |
| | | // sysLaboratory.getProject(); |
| | | this.sysLaboratoryService.updateSysLaboratory(sysLaboratory); |
| | | |
| | | FacesUtils.info("修改成功。"); |
| | |
| | | } |
| | | |
| | | this.sysLaboratoryService.deleteSysLaboratory(this.selectedList); |
| | | this.sysLaboratoryContainerService.delBySlcIds(this.selectedList); |
| | | |
| | | FacesUtils.info("删除成功。"); |
| | | } catch (Exception e) { |
| | |
| | | if (count > 0) { |
| | | list = sysLaboratoryService.getSysLaboratoryList(type, name,project, first, pageSize); |
| | | } |
| | | selectedList = new ArrayList<> (); |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public SysLaboratory getRowData(String rowKey) { |
| | | Iterator<SysLaboratory> iterator = this.iterator(); |
| | | if (iterator != null) { |
| | | SysLaboratory su = null; |
| | | while (iterator.hasNext()) { |
| | | su = iterator.next(); |
| | | if (rowKey.equals(su.getId())) { |
| | | return su; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | // Iterator<SysLaboratory> iterator = this.iterator(); |
| | | // if (iterator != null) { |
| | | // SysLaboratory su = null; |
| | | // while (iterator.hasNext()) { |
| | | // su = iterator.next(); |
| | | // if (rowKey.equals(su.getId())) { |
| | | // return su; |
| | | // } |
| | | // } |
| | | // } |
| | | Long id=Long.valueOf(rowKey); |
| | | return sysLaboratoryService.getSysLaboratory(id); |
| | | } |
| | | }; |
| | | } |