| | |
| | | import com.nanometer.smartlab.entity.*; |
| | | import com.nanometer.smartlab.entity.dto.PersonUseDetail; |
| | | import com.nanometer.smartlab.entity.enumtype.ValidFlag; |
| | | import com.nanometer.smartlab.util.ExcelUtils; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.dao.DataAccessException; |
| | | import org.springframework.dao.DataIntegrityViolationException; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | | import org.springframework.stereotype.Repository; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Resource(name = "opeReagentStatusDao") |
| | | OpeReagentStatusDao opeReagentStatusDao; |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private OpeWarehouseReserveService opeWarehouseReserveService; |
| | | @Lazy |
| | | @Resource |
| | | private OpeUseFlowService opeUseFlowService; |
| | | @Resource |
| | |
| | | private OpeUseFlowDao opeUseFlowDao; |
| | | @Resource |
| | | private OpeWarehouseReserveDao opeWarehouseReserveDao; |
| | | @Resource |
| | | private BaseRoleService baseRoleService; |
| | | |
| | | @Resource(name="baseMetaDao") |
| | | BaseMetaDao baseMetaDao; |
| | | @Resource(name = "baseMetaDao") |
| | | BaseMetaDao baseMetaDao; |
| | | |
| | | /* |
| | | * (non-Javadoc) |
| | |
| | | * java.lang.Integer) |
| | | */ |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public List<OpeReagentStatus> getOpeReagentStatusList(String reagentId, String articleNumber, Integer status, |
| | | String reagentCode, String userId, Integer first, Integer pageSize) { |
| | | public List<OpeReagentStatus> getOpeReagentStatusList(Long reagentId, String articleNumber, Integer status, |
| | | String reagentCode, Long userId, Integer first, Integer pageSize) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public List<OpeReagentStatus> getOpeReagentStatusListForLab(String name, String articleNumber, Integer status, |
| | | String reagentCode, String userId, Integer first, Integer pageSize) { |
| | | public List<OpeReagentStatus> getOpeReagentStatusList22(Long reagentId, String articleNumber, Integer status, |
| | | String reagentCode, Long userId,String applyCode, Integer first, Integer pageSize) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | |
| | | params.put("reagentId", reagentId); |
| | | params.put("articleNumber", articleNumber); |
| | | params.put("status", status); |
| | | addParamByUserId(userId, params); |
| | | if (StringUtils.isNotBlank(reagentCode)) { |
| | | params.put("reagentCode", "%" + reagentCode + "%"); |
| | | } |
| | | params.put("first", first); |
| | | params.put("pageSize", pageSize); |
| | | if (StringUtils.isNotBlank(applyCode)) { |
| | | params.put("applyCode", applyCode); |
| | | } |
| | | return this.opeReagentStatusDao.getOpeReagentStatusList22(params); |
| | | } catch (DataAccessException e) { |
| | | logger.error(e.getMessage(), e); |
| | | throw new BusinessException(ExceptionEnumCode.DB_ERR, |
| | | MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Integer getReagentStatusCountByApplyCode(String applyCode) { |
| | | return this.opeReagentStatusDao.getReagentStatusCountByApplyCode(applyCode); |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public List<OpeReagentStatus> getOpeReagentStatusListForLab(Long reagentId, String name, String articleNumber, Integer status, |
| | | String reagentCode, Long userId, String labName, Integer first, Integer pageSize) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | |
| | | params.put("name", "%" + name + "%"); |
| | | params.put("articleNumber", articleNumber); |
| | | params.put("status", status); |
| | | addParamByUserId(userId, params); |
| | | params.put("labName", labName); |
| | | // addParamByUserId(userId, params); |
| | | if (userId != null) { |
| | | SysUser sysUser = sysUserService.getSysUser(userId); |
| | | BaseRole baseRole = baseRoleService.getBaseRole(sysUser.getRoleId()); |
| | | //不是系统管理员 根据用户的课题组判断可视(用户所在课题组是否 在实验室的课题组下) |
| | | if (!"系统管理员".equals(baseRole.getName())) { |
| | | if (sysUser.getProjectId() != null) { |
| | | return null; |
| | | } |
| | | params.put("project", sysUser.getProjectId()); |
| | | } |
| | | } |
| | | if (StringUtils.isNotBlank(reagentCode)) { |
| | | params.put("reagentCode", "%" + reagentCode + "%"); |
| | | } |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public int getOpeReagentStatusTotalCountForLab(String name, String articleNumber, Integer status, String reagentCode, |
| | | String userId) { |
| | | public int getOpeReagentStatusTotalCountForLab(Long reagentId, String name, String articleNumber, Integer status, String reagentCode, |
| | | Long userId, String labName) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("name", "%" + name + "%"); |
| | | if(StringUtils.isNotBlank(name)){ |
| | | params.put("name", "%" + name + "%"); |
| | | } |
| | | |
| | | addParamByUserId(userId, params); |
| | | |
| | | // addParamByUserId(userId, params); |
| | | params.put("articleNumber", articleNumber); |
| | | if (userId != null) { |
| | | SysUser sysUser = sysUserService.getSysUser(userId); |
| | | BaseRole baseRole = baseRoleService.getBaseRole(sysUser.getRoleId()); |
| | | //不是系统管理员 根据用户的课题组判断可视(用户所在课题组是否 在实验室的课题组下) |
| | | if (!"系统管理员".equals(baseRole.getName())) { |
| | | if (sysUser.getProjectId() == null) { |
| | | return 0; |
| | | } |
| | | params.put("project", sysUser.getProjectId()); |
| | | } |
| | | } |
| | | if (StringUtils.isNotBlank(reagentCode)) { |
| | | params.put("reagentCode", "%" + reagentCode + "%"); |
| | | } |
| | | params.put("status", status); |
| | | if(StringUtils.isNotBlank(labName)){ |
| | | params.put("labName", labName); |
| | | } |
| | | return this.opeReagentStatusDao.getOpeReagentStatusTotalCountForLab(params); |
| | | } catch (DataAccessException e) { |
| | | logger.error(e.getMessage(), e); |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public int getOpeReagentStatusTotalCount(String reagentId, String articleNumber, Integer status, String reagentCode, |
| | | String userId) { |
| | | public int getOpeReagentStatusTotalCount(Long reagentId, String articleNumber, Integer status, String reagentCode, |
| | | Long userId) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("reagentId", reagentId); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public List<OpeReagentStatus> getOpeReagentStatusListByName(String reagentId, String articleNumber, Integer status, |
| | | String reagentCode, String userId, Integer first, Integer pageSize) { |
| | | public List<OpeReagentStatus> getOpeReagentStatusListByName(Long reagentId, String articleNumber, Integer status, |
| | | String reagentCode, Long userId, Integer first, Integer pageSize) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public int getOpeReagentStatusTotalCountByName(String reagentId, String articleNumber, Integer status, String reagentCode, |
| | | String userId) { |
| | | public int getOpeReagentStatusTotalCountByName(Long reagentId, String articleNumber, Integer status, String reagentCode, |
| | | Long userId) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("reagentName", reagentId); |
| | |
| | | |
| | | |
| | | @Override |
| | | public int getPersonReagentStatusTotalCountByName(String reagentId, String articleNumber, String reagentCode, |
| | | String userId,String applyPerson,Date startTime,Date endTime) { |
| | | public int getPersonReagentStatusTotalCountByName(Long reagentId, String articleNumber, String reagentCode, |
| | | Long userId, String applyPerson, Date startTime, Date endTime) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("reagentName", reagentId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<OpeReagentStatus> getPersonReagentStatusListByName(String reagentId, String articleNumber, |
| | | String reagentCode, String userId,String applyPerson,Date startTime,Date endTime, Integer first, Integer pageSize) { |
| | | public List<OpeReagentStatus> getPersonReagentStatusListByName(Long reagentId, String articleNumber, |
| | | String reagentCode, Long userId, String applyPerson, Date startTime, Date endTime, Integer first, Integer pageSize) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("reagentName", reagentId); |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public List<OpeReagentStatus> getLogOpeReagentStatusList(String reagentId, Integer status, String userId, |
| | | String loginId, Integer first, Integer pageSize) { |
| | | public List<OpeReagentStatus> getLogOpeReagentStatusList(Long reagentId, Integer status, Long userId, |
| | | Long loginId, Integer first, Integer pageSize) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public int getLogOpeReagentStatusTotalCount(String reagentId, Integer status, String userId, String loginId) { |
| | | public int getLogOpeReagentStatusTotalCount(Long reagentId, Integer status, Long userId, Long loginId) { |
| | | try { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("reagentId", reagentId); |
| | |
| | | * @param userId |
| | | * @param params |
| | | */ |
| | | private void addParamByUserId(String userId, Map<String, Object> params) { |
| | | private void addParamByUserId(Long userId, Map<String, Object> params) { |
| | | // 领用操作对话框的userid为空 |
| | | // 只有实验室管理时userid才不为空 |
| | | if (StringUtils.isNotBlank(userId)) { |
| | | if (userId != null) { |
| | | SysUser sysUser = sysUserService.getSysUser(userId); |
| | | |
| | | // // 不是管理员时,加入部门 |
| | |
| | | |
| | | // 不是管理员时,加入userid |
| | | //if (sysUser.getSeeFlag().getKey() == SeeFlag.MANAGE.getKey()||sysUser.getSeeFlag().getKey() == SeeFlag.LEADING.getKey()) { |
| | | if (sysUser.getSeeFlag().getKey() == SeeFlag.MANAGE.getKey()) { |
| | | if (sysUser.getSeeFlag().getKey() == SeeFlag.MANAGE.getKey() |
| | | && sysUser.getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) { |
| | | |
| | | } else { |
| | | params.put("userId", userId); |
| | |
| | | * @param loginId |
| | | * @param params |
| | | */ |
| | | private void addParamByLoginId(String userId, String loginId, Map<String, Object> params) { |
| | | if (StringUtils.isNotBlank(loginId)) { |
| | | private void addParamByLoginId(Long userId, Long loginId, Map<String, Object> params) { |
| | | if (loginId != null) { |
| | | SysUser sysUser = sysUserService.getSysUser(loginId); |
| | | |
| | | // 负责人,需要把部门的userid传递到SQL |
| | | if (sysUser.getSeeFlag().getKey() == SeeFlag.LEADING.getKey()) { |
| | | List<String> departmentUserIds = new ArrayList<String>(); |
| | | List<Long> departmentUserIds = new ArrayList<Long>(); |
| | | List<SysUser> departmentUsers = sysUserService.getSeeUserList(sysUser.getDepartment()); |
| | | for (SysUser departmentUser : departmentUsers) { |
| | | departmentUserIds.add(departmentUser.getId()); |
| | |
| | | params.put("departmentUserIds", departmentUserIds); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(userId)) { |
| | | if (userId != null) { |
| | | params.put("userId", userId); |
| | | } |
| | | |
| | | } else if (sysUser.getSeeFlag().getKey() == SeeFlag.NORMAL.getKey()) {// 管理员,部门的userid和个人id都不需要 |
| | | params.put("userId", userId); |
| | | } else { |
| | | if (StringUtils.isNotBlank(userId)) { |
| | | if (userId != null) { |
| | | params.put("userId", userId); |
| | | } |
| | | } |
| | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public OpeReagentStatus insertOpeReagentStatus(OpeReagentStatus opeReagentStatus) { |
| | | try { |
| | | opeReagentStatus.setId(IDUtils.uuid()); |
| | | //opeReagentStatus.setId(IDUtils.uuid()); |
| | | this.opeReagentStatusDao.insertOpeReagentStatus(opeReagentStatus); |
| | | return opeReagentStatus; |
| | | } catch (DuplicateKeyException ex) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int batchInsertOpeReagentStatus(List<OpeReagentStatus> OpeReagentStatusList) { |
| | | try { |
| | | return this.opeReagentStatusDao.batchInsertOpeReagentStatus(OpeReagentStatusList); |
| | | } catch (DuplicateKeyException ex) { |
| | | logger.warn(ex.getMessage(), ex); |
| | | throw new AlarmException(AlarmCode.DATA_DUPLICATE, |
| | | MessageUtil.getMessage(AlarmCode.DATA_DUPLICATE.getCode())); |
| | | } catch (DataIntegrityViolationException ex) { |
| | | logger.warn(ex.getMessage(), ex); |
| | | throw new AlarmException(AlarmCode.DATA_CONFICT, MessageUtil.getMessage(AlarmCode.DATA_CONFICT.getCode())); |
| | | } catch (DataAccessException ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | throw new BusinessException(ExceptionEnumCode.DB_ERR, |
| | | MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), ex); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public boolean isOpeReagentStatusExist(String reagentCode) { |
| | | try { |
| | |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public OpeReagentStatus getOpeReagentStatusByCode(String reagentCode){ |
| | | public OpeReagentStatus getOpeReagentStatusById(Long id){ |
| | | try { |
| | | return this.opeReagentStatusDao.getOpeReagentStatusByReagentCode(reagentCode); |
| | | return this.opeReagentStatusDao.getOpeReagentStatusById(id); |
| | | } catch (DataAccessException e) { |
| | | logger.error(e.getMessage(), e); |
| | | throw new BusinessException(ExceptionEnumCode.DB_ERR, |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean isAllowWarehouseUse(OpeReagentStatus opeReagentStatus) { |
| | | return opeReagentStatus != null && opeReagentStatus.getStatus() != null |
| | | && opeReagentStatus.getStatus().getKey() == ArrivalStatus.WAREHOUSE.getKey(); |
| | | && opeReagentStatus.getStatus() == ArrivalStatus.WAREHOUSE.getKey(); |
| | | } |
| | | |
| | | public boolean isAllowWarehouseUseByIds(List<String> list) { |
| | | public boolean isAllowWarehouseUseByIds(List<Long> list) { |
| | | boolean flag = true; |
| | | if (list != null && list.size() > 0) { |
| | | for (String opeReagentStatusId : list) { |
| | | OpeReagentStatus opeReagentStatus = getOpeReagentStatus(opeReagentStatusId); |
| | | for (Long opeReagentStatusId : list) { |
| | | OpeReagentStatus opeReagentStatus = getOpeReagentStatusById(opeReagentStatusId); |
| | | if (!isAllowWarehouseUse(opeReagentStatus)) { |
| | | flag = false; |
| | | break; |
| | |
| | | opeUseFlow.setPlace(opeReagentStatus.getPlace()); |
| | | opeUseFlow.setRemainder(opeReagentStatus.getRemainder()); |
| | | |
| | | Map<String, String> metaMap = new HashMap<>(); |
| | | metaMap.put("groupId", "operate_status"); |
| | | metaMap.put("metaKey", String.valueOf(OperateStatus.WAREHOUSEOUT.getKey())); |
| | | List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap); |
| | | opeUseFlow.setOperateState(baseMetaList.get(0).getId()); |
| | | opeUseFlow.setOperateState(OperateStatus.WAREHOUSEOUT.getKey()); |
| | | |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public boolean updateReagentStatus3(OpeReagentStatus opeReagentStatus) { |
| | | public boolean updateReagentStatus3(List<String> reagentCodes,Long userId,Long projectId,Long laboratoryId,Long laboratoryContainerId,String receiptNumber) { |
| | | try { |
| | | //1.判断->试剂状态是否为在仓库 |
| | | if (isAllowWarehouseUse(opeReagentStatus)) { |
| | | //1.1获得 试剂的库存选择批次 |
| | | List<OpeWarehouseReserve> owrList = this.opeWarehouseReserveService |
| | | .getOpeWarehouseReserveList(opeReagentStatus.getReagent().getId(), opeReagentStatus.getArticleNumber(),opeReagentStatus.getHouseId()); |
| | | //在同一个仓库有相同批次的试剂,根据时间早的,个数少的先扣除库存 |
| | | owrList.get(0).setReserve(owrList.get(0).getReserve() - 1); |
| | | this.opeWarehouseReserveService.updateOpeWarehouseReserve(owrList.get(0)); |
| | | for (String reagentCode : reagentCodes) { |
| | | OpeReagentStatus opeReagentStatus = this.getOpeReagentStatusByCode(reagentCode); |
| | | opeReagentStatus.setUserId(userId); |
| | | opeReagentStatus.setProjectId(projectId); |
| | | //1.判断->试剂状态是否为在仓库 |
| | | if (isAllowWarehouseUse(opeReagentStatus)) { |
| | | //1.1获得 试剂的库存选择批次 |
| | | List<OpeWarehouseReserve> owrList = this.opeWarehouseReserveService |
| | | .getOpeWarehouseReserveList(opeReagentStatus.getReagent().getId(), opeReagentStatus.getArticleNumber(), opeReagentStatus.getHouseId()); |
| | | //在同一个仓库有相同批次的试剂,根据时间早的,个数少的先扣除库存 |
| | | owrList.get(0).setReserve(owrList.get(0).getReserve() - 1); |
| | | this.opeWarehouseReserveService.updateOpeWarehouseReserve(owrList.get(0)); |
| | | } |
| | | //设置 试剂状态->领用待入库 |
| | | opeReagentStatus.setStatus(ArrivalStatus.NOREGISTER.getKey()); |
| | | opeReagentStatus.setHouseId(laboratoryId); |
| | | opeReagentStatus.setContainerId(laboratoryContainerId); |
| | | int row = this.updateOpeReagentStatus(opeReagentStatus); |
| | | |
| | | if (row == 0) { |
| | | return false; |
| | | } |
| | | |
| | | OpeUseFlow opeUseFlow = new OpeUseFlow(); |
| | | opeUseFlow.setReagentCode(opeReagentStatus.getReagentCode()); |
| | | opeUseFlow.setStatus(opeReagentStatus.getStatus()); |
| | | opeUseFlow.setHouseId(laboratoryId); |
| | | opeUseFlow.setContainerId(laboratoryContainerId); |
| | | opeUseFlow.setUserId(opeReagentStatus.getUserId()); |
| | | opeUseFlow.setPlace(opeReagentStatus.getPlace()); |
| | | opeUseFlow.setRemainder(opeReagentStatus.getRemainder()); |
| | | opeUseFlow.setReceiptNumber(receiptNumber); |
| | | |
| | | opeUseFlow.setOperateState(OperateStatus.WAREHOUSEOUT.getKey()); |
| | | |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | } |
| | | //设置 试剂状态->领用待入库 |
| | | opeReagentStatus.setStatus(ArrivalStatus.NOREGISTER); |
| | | int row = this.opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus); |
| | | |
| | | if (row == 0) { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | OpeUseFlow opeUseFlow = new OpeUseFlow(); |
| | | opeUseFlow.setReagentCode(opeReagentStatus.getReagentCode()); |
| | | opeUseFlow.setStatus(opeReagentStatus.getStatus()); |
| | | opeUseFlow.setHouseId(opeReagentStatus.getHouseId()); |
| | | opeUseFlow.setContainerId(opeReagentStatus.getContainerId()); |
| | | opeUseFlow.setUserId(opeReagentStatus.getUserId()); |
| | | opeUseFlow.setPlace(opeReagentStatus.getPlace()); |
| | | opeUseFlow.setRemainder(opeReagentStatus.getRemainder()); |
| | | |
| | | Map<String, String> metaMap = new HashMap<>(); |
| | | metaMap.put("groupId", "operate_status"); |
| | | metaMap.put("metaKey", String.valueOf(OperateStatus.WAREHOUSEOUT.getKey())); |
| | | List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap); |
| | | opeUseFlow.setOperateState(baseMetaList.get(0).getId()); |
| | | |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | |
| | | return true; |
| | | } catch (DuplicateKeyException ex) { |
| | | logger.warn(ex.getMessage(), ex); |
| | |
| | | logger.error(ex.getMessage(), ex); |
| | | throw new BusinessException(ExceptionEnumCode.DB_ERR, |
| | | MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), ex); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public boolean updateReagentStatus(OpeReagentStatus opeReagentStatus) { |
| | | public boolean updateReagentStatus(OpeReagentStatus opeReagentStatus,String receiptNumber) { |
| | | try { |
| | | |
| | | if(StringUtils.isBlank(receiptNumber)){ |
| | | throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, |
| | | MessageUtil.getMessageByCode(ExceptionEnumCode.PARAM_NO_EXIST.getCode(), "领用单号为空")); |
| | | } |
| | | if (isAllowWarehouseUse(opeReagentStatus)) { |
| | | // 减少库存 |
| | | OpeWarehouseReserve opeWarehouseReserve = this.opeWarehouseReserveService.getOpeWarehouseReserve( |
| | |
| | | opeWarehouseReserve.setReserve(opeWarehouseReserve.getReserve() - 1); |
| | | this.opeWarehouseReserveService.updateOpeWarehouseReserve(opeWarehouseReserve); |
| | | } |
| | | opeReagentStatus.setStatus(ArrivalStatus.NOREGISTER); |
| | | opeReagentStatus.setStatus(ArrivalStatus.NOREGISTER.getKey()); |
| | | int row = this.opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus); |
| | | if (row == 0) { |
| | | return false; |
| | |
| | | opeUseFlow.setUserId(opeReagentStatus.getUserId()); |
| | | opeUseFlow.setPlace(opeReagentStatus.getPlace()); |
| | | opeUseFlow.setRemainder(opeReagentStatus.getRemainder()); |
| | | opeUseFlow.setReceiptNumber(receiptNumber); |
| | | |
| | | Map<String, String> metaMap = new HashMap<>(); |
| | | metaMap.put("groupId", "operate_status"); |
| | | metaMap.put("metaKey", String.valueOf(OperateStatus.WAREHOUSEOUT.getKey())); |
| | | List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap); |
| | | opeUseFlow.setOperateState(baseMetaList.get(0).getId()); |
| | | opeUseFlow.setOperateState(OperateStatus.WAREHOUSEOUT.getKey()); |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | return true; |
| | | } catch (DuplicateKeyException ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public OpeReagentStatus getOpeReagentStatus(String id) { |
| | | public OpeReagentStatus getOpeReagentStatusByCode(String reagentCode) { |
| | | try { |
| | | return this.opeReagentStatusDao.getOpeReagentStatus(id); |
| | | return this.opeReagentStatusDao.getOpeReagentStatusByCode(reagentCode); |
| | | } catch (DataAccessException e) { |
| | | logger.error(e.getMessage(), e); |
| | | throw new BusinessException(ExceptionEnumCode.DB_ERR, |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public OpeReagentStatus getOpeReagentStatusByReagentCode2(OpeReagentStatus opeReagentStatus) { |
| | | try { |
| | | OpeReagentStatus status = this.opeReagentStatusDao.getOpeReagentStatusByReagentCode(opeReagentStatus.getReagentCode()); |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public OpeReagentStatus getOpeReagentStatusByReagentCode(String reagentCode) { |
| | | try { |
| | | OpeReagentStatus status = this.opeReagentStatusDao.getOpeReagentStatusByReagentCode(reagentCode); |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public void putReagentInLaboratory(String reagentCode, String barCode, String containerCode, SysUser sysUser) { |
| | | public void putReagentInLaboratory(String reagentCode, Long labId, Long labContainerId, Long userId) { |
| | | try { |
| | | // 检查试剂条码是否存在 |
| | | OpeReagentStatus opeReagentStatus = this.getOpeReagentStatusByReagentCode(reagentCode); |
| | |
| | | MessageUtil.getMessageByCode(ExceptionEnumCode.PARAM_NO_EXIST.getCode(), "试剂条码", reagentCode)); |
| | | } |
| | | |
| | | // 检查地点条码是否存在 |
| | | SysLaboratory sysLaboratory = this.sysLaboratoryService.getSysLaboratoryByBarCode(barCode); |
| | | if (sysLaboratory == null) { |
| | | throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, |
| | | MessageUtil.getMessageByCode(ExceptionEnumCode.PARAM_NO_EXIST.getCode(), "地点条码", barCode)); |
| | | } |
| | | // // 检查地点条码是否存在 |
| | | // SysLaboratory sysLaboratory = this.sysLaboratoryService.getSysLaboratoryByBarCode(barCode); |
| | | // if (sysLaboratory == null) { |
| | | // throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, |
| | | // MessageUtil.getMessageByCode(ExceptionEnumCode.PARAM_NO_EXIST.getCode(), "地点条码", barCode)); |
| | | // } |
| | | // |
| | | // // 检查货柜条码是否存在 |
| | | // SysLaboratoryContainer sysLaboratoryContainer = this.sysLaboratoryContainerService |
| | | // .getSysLaboratoryContainerByContainerCode(containerCode); |
| | | // if (sysLaboratoryContainer == null) { |
| | | // throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, MessageUtil |
| | | // .getMessageByCode(ExceptionEnumCode.PARAM_NO_EXIST.getCode(), "货柜条码", containerCode)); |
| | | // } |
| | | // |
| | | // // 检查货柜是否属于该地点 |
| | | // if (!sysLaboratory.getId().equals(sysLaboratoryContainer.getLaboratoryId())) { |
| | | // throw new BusinessException(ExceptionEnumCode.PARAM_ERR, "货柜不属于该地点"); |
| | | // } |
| | | |
| | | // 检查货柜条码是否存在 |
| | | SysLaboratoryContainer sysLaboratoryContainer = this.sysLaboratoryContainerService |
| | | .getSysLaboratoryContainerByContainerCode(containerCode); |
| | | if (sysLaboratoryContainer == null) { |
| | | throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, MessageUtil |
| | | .getMessageByCode(ExceptionEnumCode.PARAM_NO_EXIST.getCode(), "货柜条码", containerCode)); |
| | | } |
| | | |
| | | // 检查货柜是否属于该地点 |
| | | if (!sysLaboratory.getId().equals(sysLaboratoryContainer.getLaboratoryId())) { |
| | | throw new BusinessException(ExceptionEnumCode.PARAM_ERR, "货柜不属于该地点"); |
| | | } |
| | | |
| | | opeReagentStatus.setStatus(ArrivalStatus.LABORATORY); |
| | | opeReagentStatus.setHouseId(sysLaboratory.getId()); |
| | | opeReagentStatus.setContainerId(sysLaboratoryContainer.getId()); |
| | | opeReagentStatus.setUserId(sysUser.getId()); |
| | | opeReagentStatus.setStatus(ArrivalStatus.LABORATORY.getKey()); |
| | | opeReagentStatus.setHouseId(labId); |
| | | opeReagentStatus.setContainerId(labContainerId); |
| | | opeReagentStatus.setUserId(userId); |
| | | opeReagentStatus.setPlace(null); |
| | | this.opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus); |
| | | |
| | |
| | | opeUseFlow.setUserId(opeReagentStatus.getUserId()); |
| | | opeUseFlow.setPlace(opeReagentStatus.getPlace()); |
| | | opeUseFlow.setRemainder(opeReagentStatus.getRemainder()); |
| | | opeUseFlow.setOperateState(OperateStatus.LABORATORYIN.getKey()); |
| | | // 接口应新追加操作状态和试剂状态两个参数。 |
| | | |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public boolean store(List<OpeReagentStatus> selectedStoreList, String laboratoryId, String laboratoryContainerId) { |
| | | public boolean store(List<OpeReagentStatus> selectedStoreList, Long laboratoryId, Long laboratoryContainerId) { |
| | | try { |
| | | for (OpeReagentStatus opeReagentStatus : selectedStoreList) { |
| | | opeReagentStatus.setStatus(ArrivalStatus.LABORATORY); |
| | | opeReagentStatus.setStatus(ArrivalStatus.LABORATORY.getKey()); |
| | | opeReagentStatus.setHouseId(laboratoryId); |
| | | opeReagentStatus.setContainerId(laboratoryContainerId); |
| | | int row = this.opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus); |
| | |
| | | opeUseFlow.setPlace(opeReagentStatus.getPlace()); |
| | | opeUseFlow.setRemainder(opeReagentStatus.getRemainder()); |
| | | |
| | | Map<String, String> metaMap = new HashMap<>(); |
| | | metaMap.put("groupId", "operate_status"); |
| | | metaMap.put("metaKey", String.valueOf(OperateStatus.LABORATORYIN.getKey())); |
| | | List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap); |
| | | opeUseFlow.setOperateState(baseMetaList.get(0).getId()); |
| | | opeUseFlow.setOperateState(OperateStatus.LABORATORYIN.getKey()); |
| | | |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<OpeReagentStatus> getOpeReagentStatusInfoList(String startTime,String endTime, String containerid, String status){ |
| | | public List<OpeReagentStatus> getOpeReagentStatusInfoList(String startTime,String endTime, Long containerid, String status){ |
| | | Map params = ImmutableMap.of("startTime",startTime,"endTime",endTime,"containerid",containerid,"status",status); |
| | | return opeReagentStatusDao.getOpeReagentStatusInfoList(params); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<OpeReagentStatus> selectByReId(String id) { |
| | | public List<OpeReagentStatus> selectByReId(Long id) { |
| | | return this.opeReagentStatusDao.selectByReId(id); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByReId(String newReId, String oldReId) { |
| | | public void updateByReId(Long newReId, Long oldReId) { |
| | | Map<String, Object> params=new HashMap(); |
| | | params.put("newReId",newReId); |
| | | params.put("oldReId",oldReId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getReagentCodes(String reagentId) { |
| | | public List<String> getReagentCodes(Long reagentId) { |
| | | return opeReagentStatusDao.selectReagentCodesByReId(reagentId); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Transactional |
| | | public void orderInputWarehouseReagentStatusAndUseFlow |
| | | (OpeApplyReserve opeApplyReserve,String userId,List<String> reagentCodeList,OpeOrder opeOrder) { |
| | | (OpeApplyReserve opeApplyReserve,Long userId,List<String> reagentCodeList,OpeOrder opeOrder) { |
| | | |
| | | |
| | | for (String reagentCode : reagentCodeList) { |
| | | |
| | | //1.新增试剂状态:在仓库有 |
| | | OpeReagentStatus ors = new OpeReagentStatus(); |
| | | ors.setId(IDUtils.uuid()); |
| | | // ors.setId(IDUtils.uuid()); |
| | | //状态和用户 |
| | | ors.setStatus(ArrivalStatus.WAREHOUSE); |
| | | ors.setStatus(ArrivalStatus.WAREHOUSE.getKey()); |
| | | ors.setUserId(userId); |
| | | //入库场所 |
| | | ors.setHouseId(opeApplyReserve.getHouseId()); |
| | |
| | | |
| | | //2.更新试剂流向 |
| | | OpeUseFlow ouf = new OpeUseFlow(); |
| | | ouf.setId(IDUtils.uuid()); |
| | | // ouf.setId(IDUtils.uuid()); |
| | | //持有者 |
| | | ouf.setUserId(userId); |
| | | //在仓库状态 |
| | | ouf.setStatus(ArrivalStatus.WAREHOUSE); |
| | | //操作状态->仓库入库 |
| | | Map<String, String> metaMap = new HashMap<>(); |
| | | metaMap.put("groupId", "operate_status"); |
| | | metaMap.put("metaKey", String.valueOf(OperateStatus.WAREHOUSEIN.getKey())); |
| | | List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap); |
| | | ouf.setOperateState(baseMetaList.get(0).getId()); |
| | | ouf.setStatus(ArrivalStatus.WAREHOUSE.getKey()); |
| | | |
| | | ouf.setOperateState(OperateStatus.WAREHOUSEIN.getKey()); |
| | | //地点 |
| | | ouf.setHouseId(opeApplyReserve.getHouseId()); |
| | | ouf.setContainerId(opeApplyReserve.getContainerId()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateOpeReagentStatus(OpeReagentStatus opeReagentStatus) { |
| | | opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus); |
| | | public int updateOpeReagentStatus(OpeReagentStatus opeReagentStatus) { |
| | | return opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus); |
| | | } |
| | | |
| | | @Override |
| | | public int getReagentNumInWarehouse(String id, String articleNumber, String warehouseId) { |
| | | public int getReagentNumInWarehouse(Long id, String articleNumber, Long warehouseId) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("reagentId", id); |
| | | params.put("articleNumber", articleNumber); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 导出 |
| | | * @date 2021/4/22 10:33 |
| | | */ |
| | | @Override |
| | | public List<Map> selectExportList(String name, String articleNumber, Integer status, String reagentCode, Long userId,String labName) { |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("name", name); |
| | | params.put("articleNumber", articleNumber); |
| | | params.put("status", status); |
| | | params.put("labName", labName); |
| | | if (userId!=null) { |
| | | SysUser sysUser = sysUserService.getSysUser(userId); |
| | | BaseRole baseRole = baseRoleService.getBaseRole(sysUser.getRoleId()); |
| | | //不是系统管理员 根据用户的课题组判断可视(用户所在课题组是否 在实验室的课题组下) |
| | | if (!"系统管理员".equals(baseRole.getName())) { |
| | | if (sysUser.getProjectId()==null) { |
| | | return null; |
| | | } |
| | | params.put("project", sysUser.getProjectId()); |
| | | } |
| | | } |
| | | params.put("reagentCode", reagentCode); |
| | | return opeReagentStatusDao.selectExportList(params); |
| | | } |
| | | |
| | | @Override |
| | | public void exportLabStock2Excel(List<Map> list) throws Exception { |
| | | Map<String, String> map = new LinkedHashMap<>(); |
| | | map.put("houseName", "实验室名称"); |
| | | map.put("containerCode", "临时存储库条码"); |
| | | map.put("reagentName", "试剂名称"); |
| | | map.put("reagentCode", "试剂条形码"); |
| | | map.put("articleNumber", "批号"); |
| | | map.put("cas", "cas"); |
| | | map.put("productHome", "厂家"); |
| | | map.put("supplierName", "供应商"); |
| | | map.put("remainder", "残存量"); |
| | | ExcelUtils.export2Excel(list,"实验室库存",map); |
| | | } |
| | | |
| | | @Override |
| | | public OpeReagentStatus getStatus(Long reagentId, String reagentCode) { |
| | | |
| | | |
| | | return opeReagentStatusDao.getStatus(reagentId,reagentCode); |
| | | } |
| | | |
| | | |
| | | } |