| | |
| | | |
| | | import com.nanometer.smartlab.entity.*; |
| | | import com.nanometer.smartlab.entity.enumtype.DangerousFlag; |
| | | import com.nanometer.smartlab.entity.enumtype.ReagentTypeFlag; |
| | | import com.nanometer.smartlab.entity.enumtype.Type; |
| | | import com.nanometer.smartlab.service.*; |
| | | import com.nanometer.smartlab.util.Constants; |
| | |
| | | private SysReagent sysReagent; |
| | | private List<SysReagent> selectedList; |
| | | private String name; |
| | | private String supplierId; |
| | | private Long supplierId; |
| | | private String cas; |
| | | private List<SysSupplier> supplierSelectList; |
| | | private List<Type> typeList; |
| | |
| | | private List<BaseMeta> codeList; |
| | | private List<SysSupplier> sysSupplierList; |
| | | private List<DangerousFlag> dangerousFlagSelectList; |
| | | private List<ReagentTypeFlag> reagentTypeFlagList; |
| | | private Integer type; |
| | | |
| | | public Integer getType() { |
| | | return type == null?0:type; |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | |
| | | for (int i=0;i<list.size();i++) { |
| | | System.out.println("i=========="+i); |
| | | SysReagent re=list.get(i); |
| | | BaseMeta baseMeta=baseMetaService.getBaseMeta(re.getReagentUnit()); |
| | | String value=""; |
| | | if(baseMeta!=null){ |
| | | value=baseMeta.getMetaValue().toUpperCase(); |
| | | } |
| | | // BaseMeta baseMeta=baseMetaService.getBaseMeta(re.getReagentUnit()); |
| | | String value=re.getReagentUnit(); |
| | | // if(baseMeta!=null){ |
| | | // value=baseMeta.getMetaValue().toUpperCase(); |
| | | // } |
| | | if(re.getCas()!=null && !re.getCas().equals("")){ |
| | | String key=re.getCas()+re.getMainMetering()+value+re.getReagentFormat()+re.getProductHome(); |
| | | System.out.println("value================="+map.get(key)); |
| | |
| | | } |
| | | |
| | | public static void main(String[] args){ |
| | | Map<String,SysReagent> map=new HashMap<>(); |
| | | SysReagent s1=new SysReagent(); |
| | | s1.setCas("1"); |
| | | s1.setMainMetering(new BigDecimal(1)); |
| | | s1.setReagentUnit("0ae7ecb85f2940499680a0baa2cfc201"); |
| | | s1.setProductHome("e9cda39ea42149158e5a36618ef0bde7"); |
| | | s1.setReagentFormat("b2790196662c40529c28e616244c6d65"); |
| | | SysReagent s2=new SysReagent(); |
| | | s2.setCas("1"); |
| | | s2.setMainMetering(new BigDecimal(1)); |
| | | s2.setReagentUnit("0ae7ecb85f2940499680a0baa2cfc201"); |
| | | s2.setProductHome("e9cda39ea42149158e5a36618ef0bde7"); |
| | | s2.setReagentFormat("b2790196662c40529c28e616244c6d65"); |
| | | String key=s1.getCas()+s1.getMainMetering()+s1.getReagentUnit()+s1.getReagentFormat()+s1.getProductHome(); |
| | | map.put(key,s1); |
| | | String key2=s2.getCas()+s2.getMainMetering()+s2.getReagentUnit()+s2.getReagentFormat()+s2.getProductHome(); |
| | | map.put(key2,s2); |
| | | System.out.println(map.size()); |
| | | System.out.println(map.get(key)); |
| | | System.out.println(map.get(key2)); |
| | | |
| | | } |
| | | |
| | | public void onNewBtnClick() { |
| | |
| | | return; |
| | | } |
| | | this.sysReagent.setType(1); |
| | | if(this.sysReagent.getControlProducts().equals("")){ |
| | | this.sysReagent.setControlProducts(null); |
| | | } |
| | | this.sysReagentService.insertSysReagent(this.sysReagent); |
| | | |
| | | FacesUtils.info("新建成功。"); |
| | |
| | | } |
| | | |
| | | //判断字典表里是否存在这组键值对 |
| | | public String getId(String groupId,String metaValue){ |
| | | String id=""; |
| | | public Long getId(String groupCode,String metaValue){ |
| | | Long id=null; |
| | | if(this.codeList.size()>0){ |
| | | for (BaseMeta bm:this.codeList){ |
| | | |
| | | if(bm.getGroupId().equals(groupId)&&bm.getMetaValue().equals(metaValue)){ |
| | | if(bm.getGroupCode().equals(groupCode)&&bm.getMetaValue().equals(metaValue)){ |
| | | id=bm.getId(); |
| | | } |
| | | } |
| | |
| | | return id; |
| | | } |
| | | //判断字典表里计量单位是否存在这组键值对,忽略大小写 |
| | | public String getIdForUnit(String groupId,String metaValue){ |
| | | String id=""; |
| | | public Long getIdForUnit(String groupCode,String metaValue){ |
| | | Long id=null; |
| | | if(this.codeList.size()>0){ |
| | | for (BaseMeta bm:this.codeList){ |
| | | |
| | | if(bm.getGroupId().equals(groupId)&&bm.getMetaValue().toUpperCase().equals(metaValue.toUpperCase())){ |
| | | if(bm.getGroupCode().equals(groupCode)&&bm.getMetaValue().toUpperCase().equals(metaValue.toUpperCase())){ |
| | | id=bm.getId(); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | //判断是否存在改供应商 |
| | | public String getSysSupplierId(String name){ |
| | | String id=""; |
| | | public Long getSysSupplierId(String name){ |
| | | Long id=null; |
| | | for (SysSupplier sup:this.sysSupplierList) { |
| | | if(sup.getName().equals(name)){ |
| | | id=sup.getId(); |
| | |
| | | Sheet sheet=wb.getSheetAt(0); |
| | | List<SysReagent> sysReagentsList = new ArrayList<>(); |
| | | int totalRows = sheet.getPhysicalNumberOfRows(); |
| | | |
| | | Row row=null; |
| | | int totalCells=0; |
| | | String dangours = ""; |
| | | totalCells=sheet.getRow(0).getLastCellNum(); |
| | | if(totalCells>7){ |
| | | FacesUtils.warn("导入表格格式不正确"); |
| | | return; |
| | | } |
| | | for (int i = 1; i < totalRows; i++) { |
| | | SysReagent sysReagent = new SysReagent(); |
| | | List<String> valuesList=new ArrayList<String>(); |
| | | List<Object> valuesList=new ArrayList<Object>(); |
| | | row=sheet.getRow(i); |
| | | |
| | | totalCells= row.getLastCellNum(); |
| | | // totalCells= row.getLastCellNum(); |
| | | // if(totalCells>7){ |
| | | // FacesUtils.warn("导入表格格式不正确"); |
| | | // return; |
| | | // } |
| | | for (int t = 0; t < totalCells; t++) { |
| | | String cellInfo=""; |
| | | String groupId = ""; |
| | | String groupCode = ""; |
| | | if (row.getCell(t) != null) { |
| | | if (row.getCell(t).getCellTypeEnum().toString().equals("NUMERIC")) { |
| | | cellInfo = String.valueOf(row.getCell(t).getNumericCellValue()); |
| | |
| | | cellInfo = row.getCell(t).getStringCellValue(); |
| | | } |
| | | } |
| | | if(t == 1 ){ |
| | | groupId = "product_name"; |
| | | String id=getId(groupId,cellInfo); |
| | | if(id == "" && cellInfo!=null && cellInfo!="" ) { |
| | | BaseMeta baseMeta = new BaseMeta(); |
| | | baseMeta.setId(IDUtils.uuid()); |
| | | baseMeta.setGroupId(groupId); |
| | | baseMeta.setMetaValue(cellInfo); |
| | | baseMeta.setMetaKey(cellInfo); |
| | | baseMetaService.insertBaseMeta(baseMeta); |
| | | id = baseMeta.getId(); |
| | | this.codeList.add(baseMeta); |
| | | } |
| | | valuesList.add(id); |
| | | }else if(t==3){ |
| | | if(t==3){ |
| | | String numberStr = ""; |
| | | String ChartStr = ""; |
| | | char[] strArr = cellInfo.toCharArray(); |
| | |
| | | } |
| | | numberStr=cellInfo.substring(0,index); |
| | | ChartStr=cellInfo.substring(index,cellInfo.length()); |
| | | System.out.println("ChartStr========"+ChartStr); |
| | | /*for (char string : strArr) { |
| | | // 判断是否为字母 |
| | | if ((string+"").matches("^[a-zA-Z\\u4e00-\\u9fa5]+$")||(string+"").equals("/")){ |
| | | ChartStr += string; |
| | | } |
| | | // 判断是否为数字 |
| | | if ((string+"").matches("[0-9]")){ |
| | | numberStr += string; |
| | | } |
| | | |
| | | }*/ |
| | | valuesList.add(numberStr); |
| | | groupId = "reagent_unit"; |
| | | String id=getIdForUnit(groupId,ChartStr); |
| | | if(id == "" && cellInfo!=null && cellInfo!="") { |
| | | BaseMeta baseMeta = new BaseMeta(); |
| | | baseMeta.setId(IDUtils.uuid()); |
| | | baseMeta.setGroupId(groupId); |
| | | baseMeta.setMetaValue(ChartStr.toUpperCase()); |
| | | baseMeta.setMetaKey(ChartStr.toUpperCase()); |
| | | baseMetaService.insertBaseMeta(baseMeta); |
| | | id = baseMeta.getId(); |
| | | this.codeList.add(baseMeta); |
| | | valuesList.add(ChartStr.toUpperCase()); |
| | | }else if(t==5){ |
| | | Long id=null; |
| | | if(!StringUtils.isBlank(cellInfo)){ |
| | | SysSupplier sysSupplier=sysSupplierService.getSysSupplierByName(cellInfo); |
| | | if(sysSupplier==null){//新建供应商 |
| | | FacesUtils.warn("未查询到供该应商信息-"+cellInfo); |
| | | return; |
| | | } |
| | | id=sysSupplier.getId(); |
| | | } |
| | | valuesList.add(id); |
| | | }else { |
| | |
| | | } |
| | | |
| | | } |
| | | if (valuesList.size() != 6){ |
| | | break; |
| | | if (valuesList.size() != 8){ |
| | | FacesUtils.warn("excel数据解析格式失败"); |
| | | return; |
| | | } |
| | | System.out.println("value : "+valuesList); |
| | | sysReagent.setName(valuesList.get(0));//试剂名称 |
| | | sysReagent.setProductHome(valuesList.get(1));//厂家 |
| | | sysReagent.setProductSn(valuesList.get(2));//产品编号 |
| | | sysReagent.setCas(valuesList.get(2));//产品编号 |
| | | sysReagent.setName(valuesList.get(0).toString());//试剂名称 |
| | | sysReagent.setProductHome(valuesList.get(1).toString());//厂家 |
| | | sysReagent.setProductSn(valuesList.get(2).toString());//产品编号 |
| | | sysReagent.setCas(valuesList.get(2).toString());//产品编号 |
| | | if(!valuesList.get(3).equals("")){ |
| | | sysReagent.setMainMetering(new BigDecimal(valuesList.get(3)));//包装(数值) |
| | | sysReagent.setMainMetering(new BigDecimal(valuesList.get(3).toString()));//包装(数值) |
| | | } |
| | | sysReagent.setReagentUnit(valuesList.get(4));//包装(单位) |
| | | sysReagent.setReagentUnit(valuesList.get(4).toString());//包装(单位) |
| | | if(!valuesList.get(5).equals("")){ |
| | | sysReagent.setPrice(BigDecimal.valueOf(Double.parseDouble(valuesList.get(5))));//含税单价 |
| | | sysReagent.setPrice(BigDecimal.valueOf(Double.parseDouble(valuesList.get(5).toString())));//含税单价 |
| | | } |
| | | if(StringUtils.isNotBlank(valuesList.get(6).toString())){ |
| | | sysReagent.setSupplierId(Long.valueOf(valuesList.get(6).toString()));//供应商id |
| | | } |
| | | if(StringUtils.isNotBlank(valuesList.get(7).toString())){ |
| | | sysReagent.setReagentFormat(valuesList.get(7).toString());//规格 |
| | | } |
| | | DangerousFlag d; |
| | | d = DangerousFlag.NORMAL; |
| | |
| | | FacesUtils.info("导入成功。"); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | FacesUtils.info("导入失败。"); |
| | | FacesUtils.info("导入失败,"+ex.getMessage()); |
| | | } |
| | | } |
| | | //导入 |
| | |
| | | for (int t = 0; t <= totalCells; t++) { |
| | | //System.out.println(row.getCell(t)); |
| | | String cellInfo=""; |
| | | String groupId = ""; |
| | | String groupCode = ""; |
| | | |
| | | if (row.getCell(t) != null) { |
| | | |
| | |
| | | cellInfo = row.getCell(t).getStringCellValue(); |
| | | } |
| | | } |
| | | if(t == 2 || t == 3 || t == 7 || t == 10 || t == 9){ |
| | | if( t == 2){ |
| | | groupId = "control_products"; |
| | | }else if(t == 3){ |
| | | groupId = "reagent_format"; |
| | | }else if (t==7){ |
| | | groupId = "reagent_character"; |
| | | dangours = cellInfo; |
| | | }else if(t == 10){ |
| | | groupId = "reagent_type"; |
| | | }else if(t == 9){ |
| | | groupId = "product_name"; |
| | | } |
| | | //String id = sysSupplierService.getSysSupplierId(cellInfo,groupId); |
| | | String id=getId(groupId,cellInfo); |
| | | if(id == "" && cellInfo!=null && cellInfo!="" ) { |
| | | BaseMeta baseMeta = new BaseMeta(); |
| | | baseMeta.setId(IDUtils.uuid()); |
| | | baseMeta.setGroupId(groupId); |
| | | baseMeta.setMetaValue(cellInfo); |
| | | baseMeta.setMetaKey(cellInfo); |
| | | baseMetaService.insertBaseMeta(baseMeta); |
| | | id = baseMeta.getId(); |
| | | this.codeList.add(baseMeta); |
| | | } |
| | | valuesList.add(id); |
| | | }else if(t == 4){ |
| | | if(t == 4){ |
| | | String numberStr = ""; |
| | | String ChartStr = ""; |
| | | char[] strArr = cellInfo.toCharArray(); |
| | |
| | | if ((string+"").matches("^[a-zA-Z\\u4e00-\\u9fa5]|[μ]+$")||(string+"").equals("/")){ |
| | | ChartStr += string; |
| | | } |
| | | |
| | | } |
| | | numberStr = cellInfo.replace(ChartStr, ""); |
| | | |
| | | valuesList.add(numberStr); |
| | | groupId = "reagent_unit"; |
| | | //String id = sysSupplierService.getSysSupplierId(ChartStr,groupId); |
| | | String id=getIdForUnit(groupId,ChartStr.toUpperCase()); |
| | | if(id == "" && cellInfo!=null && cellInfo!="") { |
| | | BaseMeta baseMeta = new BaseMeta(); |
| | | baseMeta.setId(IDUtils.uuid()); |
| | | baseMeta.setGroupId(groupId); |
| | | baseMeta.setMetaValue(ChartStr.toUpperCase()); |
| | | baseMeta.setMetaKey(ChartStr.toUpperCase()); |
| | | baseMetaService.insertBaseMeta(baseMeta); |
| | | id = baseMeta.getId(); |
| | | this.codeList.add(baseMeta); |
| | | } |
| | | //System.out.println(getId(groupId,cellInfo)); |
| | | valuesList.add(id); |
| | | valuesList.add(ChartStr.toUpperCase()); |
| | | }else if(t == 11){ |
| | | String id=getSysSupplierId(cellInfo); |
| | | if(id == "" && cellInfo!=null && cellInfo!="") { |
| | | Long id=getSysSupplierId(cellInfo); |
| | | if(id == null && cellInfo!=null && cellInfo!="") { |
| | | SysSupplier sup=new SysSupplier(); |
| | | sup.setId(IDUtils.uuid()); |
| | | // sup.setId(IDUtils.uuid()); |
| | | sup.setName(cellInfo); |
| | | sup.setPersonName(""); |
| | | sup.setPhone(""); |
| | |
| | | this.sysSupplierList.add(sup); |
| | | this.supplierSelectList.add(sup); |
| | | } |
| | | valuesList.add(id); |
| | | valuesList.add(String.valueOf(id)); |
| | | }/*else if(t == 9){ |
| | | valuesList.add(sysSupplierService.getSysSupplierIdByname(cellInfo)); |
| | | }*/else{ |
| | | valuesList.add(cellInfo); |
| | | //if(cellInfo!=null) |
| | | valuesList.add(cellInfo); |
| | | } |
| | | } |
| | | if (valuesList.size() != 13){ |
| | | /* if (valuesList.size() != 13){ |
| | | break; |
| | | } |
| | | }*/ |
| | | |
| | | sysReagent.setProductSn(valuesList.get(0));//产品编号 |
| | | sysReagent.setName(valuesList.get(1));//试剂名称 |
| | |
| | | } |
| | | sysReagent.setProductHome(valuesList.get(10));//厂家 |
| | | sysReagent.setReagentType(valuesList.get(11));//试剂类型 |
| | | sysReagent.setSupplierId(valuesList.get(12));//供应商 |
| | | sysReagent.setSupplierId(Long.valueOf(valuesList.get(12)));//供应商 |
| | | DangerousFlag d; |
| | | if(dangours.equals("普货")){ |
| | | d = DangerousFlag.NORMAL; |
| | |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | return sysReagentService.getSysReagent(rowKey); |
| | | Long id=Long.valueOf(rowKey); |
| | | return sysReagentService.getSysReagent(id); |
| | | } |
| | | }; |
| | | } |
| | |
| | | } |
| | | |
| | | public List<SysReagent> getSelectedList() { |
| | | return selectedList; |
| | | return this.selectedList; |
| | | } |
| | | |
| | | public void setSelectedList(List<SysReagent> selectedList) { |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getSupplierId() { |
| | | public Long getSupplierId() { |
| | | return supplierId; |
| | | } |
| | | |
| | | public void setSupplierId(String supplierId) { |
| | | public void setSupplierId(Long supplierId) { |
| | | this.supplierId = supplierId; |
| | | } |
| | | |
| | |
| | | return dangerousFlagSelectList; |
| | | } |
| | | |
| | | public List<ReagentTypeFlag> getReagentTypeFlagList() { |
| | | if (this.reagentTypeFlagList == null) { |
| | | this.reagentTypeFlagList = Arrays.asList(ReagentTypeFlag.values()); |
| | | } |
| | | |
| | | return reagentTypeFlagList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void setDangerousFlagSelectList(List<DangerousFlag> dangerousFlagSelectList) { |
| | | this.dangerousFlagSelectList = dangerousFlagSelectList; |
| | | } |