| | |
| | | package com.ruoyi.warehouse.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.warehouse.pojo.Documentation; |
| | | import com.ruoyi.warehouse.pojo.DocumentationBorrowManagement; |
| | | import com.ruoyi.warehouse.service.DocumentationBorrowManagementService; |
| | | import com.ruoyi.warehouse.mapper.DocumentationBorrowManagementMapper; |
| | | import com.ruoyi.warehouse.service.DocumentationService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author 86151 |
| | |
| | | * @createDate 2025-08-14 15:55:45 |
| | | */ |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class DocumentationBorrowManagementServiceImpl extends ServiceImpl<DocumentationBorrowManagementMapper, DocumentationBorrowManagement> |
| | | implements DocumentationBorrowManagementService{ |
| | | @Autowired |
| | | private DocumentationBorrowManagementMapper documentationBorrowManagementMapper; |
| | | @Autowired |
| | | private DocumentationService documentationService; |
| | | @Override |
| | | public IPage<DocumentationBorrowManagement> listPage(Page page, DocumentationBorrowManagement documentationBorrowManagement) { |
| | | |
| | | return null; |
| | | IPage<DocumentationBorrowManagement> listPage = documentationBorrowManagementMapper.listPage(page, documentationBorrowManagement); |
| | | return listPage; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response) { |
| | | // List<DocumentationBorrowManagement> list =documentationBorrowManagementMapper.list(); |
| | | // ExcelUtil<DocumentationBorrowManagement> util = new ExcelUtil<>(DocumentationBorrowManagement.class); |
| | | // util.exportExcel(response, list, "文档借阅-归还记录"); |
| | | public boolean add(DocumentationBorrowManagement documentationBorrowManagement) { |
| | | Long documentationId = documentationBorrowManagement.getDocumentationId(); |
| | | String borrowStatus = documentationBorrowManagement.getBorrowStatus(); |
| | | Documentation documentation = documentationService.getById(documentationId); |
| | | if (documentation==null){ |
| | | System.out.println("文档不存在"); |
| | | return false; |
| | | } |
| | | if ("借出".equals(documentation.getDocStatus())){ |
| | | if ("归还".equals(borrowStatus)){ |
| | | documentation.setDocStatus("正常"); |
| | | documentationService.updateById(documentation); |
| | | documentationBorrowManagementMapper.insert(documentationBorrowManagement); |
| | | return true; |
| | | }else{ |
| | | System.out.println("文档已借出,不能重复借出"); |
| | | return false; |
| | | } |
| | | }else if("正常".equals(documentation.getDocStatus())){ |
| | | if ("归还".equals(borrowStatus)){ |
| | | System.out.println("文档已归还,不能重复归还"); |
| | | return false; |
| | | }else if("借出".equals(borrowStatus)){ |
| | | documentation.setDocStatus("借出"); |
| | | documentationService.updateById(documentation); |
| | | documentationBorrowManagementMapper.insert(documentationBorrowManagement); |
| | | return true; |
| | | } |
| | | }else{ |
| | | System.out.println("文档状态异常"); |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | // @Override |
| | | // public boolean updateDBMById(DocumentationBorrowManagement documentationBorrowManagement) { |
| | | // Long id = documentationBorrowManagement.getId(); |
| | | //// Long documentationId = documentationBorrowManagement.getDocumentationId(); |
| | | // //查询文档是否已归还 |
| | | // DocumentationBorrowManagement dbm = documentationBorrowManagementMapper.selectById(id); |
| | | //// Long documentationId = dbm.getDocumentationId(); |
| | | // if ("归还".equals(dbm.getBorrowStatus())){ |
| | | // System.out.println("文档已归还,不能更新"); |
| | | // return false; |
| | | // } |
| | | // //查询文档 |
| | | // Documentation documentation = documentationService.getById(dbm.getDocumentationId()); |
| | | // String docStatus = documentation.getDocStatus(); |
| | | // if ("正常".equals(docStatus)){ |
| | | // System.out.println("文档已归还,不能更新"); |
| | | // return false; |
| | | // } |
| | | // return false; |
| | | // } |
| | | |
| | | @Override |
| | | public boolean deleteByIds(List<Long> ids) { |
| | | List<DocumentationBorrowManagement> list = documentationBorrowManagementMapper.selectList(new LambdaQueryWrapper<DocumentationBorrowManagement>().in(DocumentationBorrowManagement::getId, ids)); |
| | | for (DocumentationBorrowManagement documentationBorrowManagement : list) { |
| | | String borrowStatus = documentationBorrowManagement.getBorrowStatus(); |
| | | if ("借阅".equals(borrowStatus)){ |
| | | System.out.println("文档已借出,不能删除"); |
| | | return false; |
| | | } |
| | | } |
| | | documentationBorrowManagementMapper.deleteBatchIds(ids); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |