| | |
| | | package com.nanometer.smartlab.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.nanometer.smartlab.dao.SysLaboratoryDao; |
| | | import com.nanometer.smartlab.entity.SysLaboratory; |
| | | import com.nanometer.smartlab.entity.SysLaboratoryContainer; |
| | | import com.nanometer.smartlab.entity.SysWarehouseContainer; |
| | | import com.nanometer.smartlab.exception.BusinessException; |
| | | import com.nanometer.smartlab.exception.ExceptionEnumCode; |
| | | import com.nanometer.smartlab.service.SysLaboratoryContainerService; |
| | | import com.nanometer.smartlab.service.SysLaboratoryService; |
| | | import com.nanometer.smartlab.service.SysWarehouseContainerService; |
| | | import org.apache.log4j.Logger; |
| | | import org.primefaces.context.RequestContext; |
| | | import org.primefaces.model.LazyDataModel; |
| | |
| | | |
| | | @Resource |
| | | private SysWarehouseService sysWarehouseService; |
| | | @Resource |
| | | private SysLaboratoryDao sysLaboratoryDao; |
| | | @Resource |
| | | private SysLaboratoryContainerService sysLaboratoryContainerService; |
| | | @Resource |
| | | private SysWarehouseContainerService sysWarehouseContainerService; |
| | | |
| | | /** |
| | | * 数据源 |
| | |
| | | /** |
| | | * 数据模型 |
| | | */ |
| | | private SysWarehouse sysWarehouse; |
| | | private SysWarehouse sysWarehouse=new SysWarehouse(); |
| | | /** |
| | | * 选中的list |
| | | */ |
| | |
| | | return; |
| | | } |
| | | |
| | | this.sysWarehouseService.updateSysWarehouse(sysWarehouse); |
| | | SysLaboratory sysLaboratory = sysLaboratoryDao.getSysLaboratoryByName(sysWarehouse.getName()); |
| | | if (sysLaboratory != null) { |
| | | this.sysWarehouseService.updateSysWarehouse2(sysWarehouse,sysLaboratory); |
| | | } else { |
| | | this.sysWarehouseService.updateSysWarehouse(sysWarehouse); |
| | | } |
| | | |
| | | |
| | | FacesUtils.info("修改成功。"); |
| | | RequestContext.getCurrentInstance().execute("PF('dialog').hide()"); |
| | |
| | | FacesUtils.warn("请选择数据。"); |
| | | return; |
| | | } |
| | | |
| | | //判断下面是否有柜子,有就拒绝删除 |
| | | for (SysWarehouse sysWarehouse : selectedList) { |
| | | List<SysWarehouseContainer> list = sysWarehouseContainerService.getSysWarehouseContainerList(sysWarehouse.getId()); |
| | | if (list.size() > 0) { |
| | | throw new BusinessException(ExceptionEnumCode.SYS_ERR, "该仓库下还有货柜,请清除货柜后删除仓库"); |
| | | } |
| | | } |
| | | this.sysWarehouseService.deleteSysWarehouse(this.selectedList); |
| | | |
| | | FacesUtils.info("删除成功。"); |
| | | } catch (BusinessException e) { |
| | | logger.error(e.getMessage()); |
| | | FacesUtils.warn(e.getMessage()); |
| | | } catch (Exception e) { |
| | | logger.error("操作失败。", e); |
| | | FacesUtils.warn("操作失败。"); |
| | |
| | | if (count > 0) { |
| | | list = sysWarehouseService.getSysWarehouseList(type, name, first, pageSize); |
| | | } |
| | | selectedList = new ArrayList<>(); |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public SysWarehouse getRowData(String rowKey) { |
| | | Iterator<SysWarehouse> iterator = this.iterator(); |
| | | if (iterator != null) { |
| | | SysWarehouse su = null; |
| | | while (iterator.hasNext()) { |
| | | su = iterator.next(); |
| | | if (rowKey.equals(su.getId())) { |
| | | return su; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | // Iterator<SysWarehouse> iterator = this.iterator(); |
| | | // if (iterator != null) { |
| | | // SysWarehouse su = null; |
| | | // while (iterator.hasNext()) { |
| | | // su = iterator.next(); |
| | | // if (rowKey.equals(su.getId())) { |
| | | // return su; |
| | | // } |
| | | // } |
| | | // } |
| | | Long id=Long.valueOf(rowKey); |
| | | return sysWarehouseService.getSysWarehouse(id); |
| | | } |
| | | }; |
| | | } |