| | |
| | | import com.nanometer.smartlab.dao.SysLaboratoryDao; |
| | | import com.nanometer.smartlab.dao.SysUserDao; |
| | | import com.nanometer.smartlab.entity.SysLaboratory; |
| | | import com.nanometer.smartlab.entity.SysProject; |
| | | import com.nanometer.smartlab.entity.SysUser; |
| | | import com.nanometer.smartlab.entity.dto.LaboratoryVo; |
| | | import com.nanometer.smartlab.exception.AlarmCode; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by cmower on 17/11/20. |
| | |
| | | @Resource |
| | | SysUserDao sysUserDao; |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public List<SysLaboratory> getSysLaboratoryList(String type, String name,String project,Integer first, Integer pageSize) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | |
| | | return commonPage; |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | |
| | | public int getSysLaboratoryTotalCount(String type, String name,String project) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public SysLaboratory getSysLaboratory(String id) { |
| | | public SysLaboratory getSysLaboratory(Long id) { |
| | | try { |
| | | return this.sysLaboratoryDao.getSysLaboratory(id); |
| | | } catch (DataAccessException e) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public SysLaboratory getSysLaboratorySimpleInfo(Long id) { |
| | | try { |
| | | return this.sysLaboratoryDao.getSysLaboratorySimpleInfo(id); |
| | | } catch (DataAccessException e) { |
| | | logger.error(e.getMessage(), e); |
| | | throw new BusinessException(ExceptionEnumCode.DB_ERR, |
| | | MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e); |
| | | } |
| | | } |
| | | |
| | | public SysLaboratory insertSysLaboratory(SysLaboratory sysLaboratory) { |
| | | try { |
| | | if (sysLaboratory.getId() == null) { |
| | | sysLaboratory.setId(IDUtils.uuid()); |
| | | } |
| | | // if (sysLaboratory.getId() == null) { |
| | | // sysLaboratory.setId(IDUtils.uuid()); |
| | | // } |
| | | this.sysLaboratoryDao.insertSysLaboratory(sysLaboratory); |
| | | return sysLaboratory; |
| | | } catch (DuplicateKeyException ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public boolean updateSysLaboratory(SysLaboratory sysLaboratory) { |
| | | try { |
| | | int row = this.sysLaboratoryDao.updateSysLaboratory(sysLaboratory); |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | |
| | | public boolean deleteSysLaboratory(List<SysLaboratory> sysLaboratoryList) { |
| | | try { |
| | | if (sysLaboratoryList == null || sysLaboratoryList.size() == 0) { |
| | | return false; |
| | | } |
| | | |
| | | List<String> ids = new ArrayList<String>(); |
| | | List<Long> ids = new ArrayList<Long>(); |
| | | for (SysLaboratory sysLaboratory : sysLaboratoryList) { |
| | | ids.add(sysLaboratory.getId()); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public boolean isSysLaboratoryExist(String barCode, String editId) { |
| | | |
| | | public boolean isSysLaboratoryExist(String barCode, Long editId) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("barCode", barCode); |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | |
| | | public SysLaboratory getSysLaboratoryByBarCode(String barCode) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | |
| | | sysLaboratory.setId(sysLaboratoryTmpl.getId()); |
| | | this.sysLaboratoryDao.updateLabExport(sysLaboratory); |
| | | }else{ |
| | | if (sysLaboratoryTmpl == null) { |
| | | sysLaboratory.setId(IDUtils.uuid()); |
| | | } |
| | | // if (sysLaboratoryTmpl == null) { |
| | | // sysLaboratory.setId(IDUtils.uuid()); |
| | | // } |
| | | this.sysLaboratoryDao.insertSysLaboratory(sysLaboratory); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void exportLab2Excel(List<Map> list) throws Exception { |
| | | public void exportLab2Excel(List<SysLaboratory> list) throws Exception { |
| | | |
| | | Map<String, String> map = new LinkedHashMap<>(); |
| | | map.put("type", "类型"); |
| | |
| | | map.put("location", "地址"); |
| | | map.put("department", "部门"); |
| | | map.put("project", "课题组"); |
| | | ExcelUtils.export2Excel(list,"实验室信息",map); |
| | | List<Map> labList=new ArrayList<>(); |
| | | for(SysLaboratory sysLaboratory:list){ |
| | | Map<String,Object> labmap=new HashMap<>(); |
| | | labmap.put("type",sysLaboratory.getTypeName()); |
| | | labmap.put("name",sysLaboratory.getName()); |
| | | labmap.put("infoCode",sysLaboratory.getInfoCode()); |
| | | labmap.put("barCode",sysLaboratory.getBarCode()); |
| | | labmap.put("location",sysLaboratory.getLocation()); |
| | | labmap.put("department",sysLaboratory.getDepartmentName()); |
| | | List<SysProject> projects=sysLaboratory.getProjects(); |
| | | List<String> projectNames=new ArrayList<>(); |
| | | if(projects!=null&&projects.size()>0){ |
| | | projectNames=projects.stream().map(SysProject::getProjectName).collect(Collectors.toList()); |
| | | } |
| | | labmap.put("project",String.join(",",projectNames)); |
| | | labList.add(labmap); |
| | | } |
| | | ExcelUtils.export2Excel(labList,"实验室信息",map); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> exportLabList(String type, String name,String project) { |
| | | public List<SysLaboratory> exportLabList(String type, String name,String project) { |
| | | Map<String,String> params = new HashMap<>(); |
| | | params.put("type", type); |
| | | params.put("name", name); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<LaboratoryVo.Laboratory> getLaboratoryByProject(String project) { |
| | | return sysLaboratoryDao.getLaboratoryByProject(project); |
| | | public List<LaboratoryVo.Laboratory> getLaboratoryByProject(Long projectId) { |
| | | return sysLaboratoryDao.getLaboratoryByProject(projectId); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysLaboratory> getSysLaboratoryListByUserId(String userId) { |
| | | public List<SysLaboratory> getSysLaboratoryListByUserId(Long userId) { |
| | | //1.根据用户的课题组获取实验室,没有就按照部门 |
| | | SysUser user = sysUserDao.getSysUser(userId); |
| | | Map<String,Object> params = new HashMap<>(); |
| | | if (StringUtils.isNotBlank(user.getProject())){ |
| | | params.put("project", user.getProject()); |
| | | if (user.getProjectId()!=null){ |
| | | params.put("project", user.getProjectId()); |
| | | List<SysLaboratory> list = sysLaboratoryDao.getSysLaboratoryList(params); |
| | | if (list.size() < 1) { |
| | | return this.getSysLaboratoryListByDep(user.getDepartment()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public List<SysLaboratory> getSysLaboratoryListByDep(String depId) { |
| | | public List<SysLaboratory> getLaboratoryByProjectId(Long projectId) { |
| | | return sysLaboratoryDao.getLaboratoryByProjectId(projectId); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<SysLaboratory> getSysLaboratoryListByDep(Long depId) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | if (StringUtils.isNotBlank(depId)) { |
| | | if (depId!=null) { |
| | | params.put("department", depId); |
| | | } |
| | | return this.sysLaboratoryDao.getSysLaboratoryList(params); |