src/main/java/com/ruoyi/warehouse/controller/DocumentClassificationController.java
@@ -26,8 +26,8 @@ private DocumentClassificationService documentClassificationService; //树结构 @GetMapping("/getList") public List<DocumentClassificationTreeDto> getList(DocumentClassificationDto documentClassificationDto) { return documentClassificationService.selectDocumentClassificationList(documentClassificationDto); public List<DocumentClassificationTreeDto> getList() { return documentClassificationService.selectDocumentClassificationList(); } @PostMapping("/add") @ApiOperation("文档分类-添加") src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesController.java
@@ -29,7 +29,7 @@ @ApiOperation("商品货架-查询") @Log(title = "商品货架-查询", businessType = BusinessType.OTHER) public AjaxResult listById(@RequestBody WarehouseGoodsShelves warehouseGoodsShelves) { List<WarehouseGoodsShelves> list = warehouseGoodsShelvesService.findList(warehouseGoodsShelves); List<WarehouseGoodsShelvesDto> list = warehouseGoodsShelvesService.findList(warehouseGoodsShelves); return AjaxResult.success(list); } @PostMapping("/add") src/main/java/com/ruoyi/warehouse/dto/DocumentationBorrowManagementDto.java
@@ -17,4 +17,9 @@ */ @Excel(name = "借阅人") private String nickName; /** * 归还人 */ @Excel(name = "归还人") private String returnNickName; } src/main/java/com/ruoyi/warehouse/dto/ReturnExportDto.java
@@ -8,21 +8,20 @@ import java.time.LocalDateTime; public class ReturnExportDto { private String id; // 记录编号 @Excel(name = "文档名称") private String docName; // 文档名称 @Excel(name = "原借阅人") private String nickName; // 借阅人 @Excel(name = "归还时间", dateFormat = "yyyy-MM-dd", width = 30) @Excel(name = "借阅时间", dateFormat = "yyyy-MM-dd", width = 30) @JsonFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDateTime borrowTime; // 借阅时间(可能需要保留) private LocalDateTime borrowDate; // 借阅时间 @Excel(name = "归还人") @NotBlank(message = "归还人不能为空!!") private String returnNickName; // 归还人 @Excel(name = "归还时间", dateFormat = "yyyy-MM-dd", width = 30) @JsonFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDateTime updateTime; // 归还时间 private LocalDateTime returnDate; // 归还时间 } src/main/java/com/ruoyi/warehouse/dto/WarehouseDto.java
@@ -10,7 +10,4 @@ private String goodsShelvesName; private String category; // private List<DocumentationDto> documentationList; // private List<WarehouseGoodsShelvesRowcolDto> warehouseGoodsShelvesRowcolList; private List<WarehouseGoodsShelvesDto> warehouseGoodsShelvesList; } src/main/java/com/ruoyi/warehouse/dto/WarehouseGoodsShelvesDto.java
@@ -6,8 +6,7 @@ public class WarehouseGoodsShelvesDto extends WarehouseGoodsShelves { private String warehouseName; private String goodsShelvesName; // private List<DocumentationDto> documentationList; private List<WarehouseGoodsShelvesRowcolDto> warehouseGoodsShelvesRowcolList; private String docName; private String docNumber; private String category; } src/main/java/com/ruoyi/warehouse/dto/WarehouseGoodsShelvesRowcolDto.java
@@ -10,6 +10,7 @@ public class WarehouseGoodsShelvesRowcolDto extends WarehouseGoodsShelvesRowcol { private String warehouseName; private String goodsShelvesName; private List<DocumentationDto> documentationList; private String docName; private String docNumber; private String category; } src/main/java/com/ruoyi/warehouse/mapper/WarehouseGoodsShelvesMapper.java
@@ -21,7 +21,7 @@ public interface WarehouseGoodsShelvesMapper extends BaseMapper<WarehouseGoodsShelves> { List<WarehouseGoodsShelvesDto> findList(@Param("warehouseGoodsShelves") WarehouseGoodsShelves warehouseGoodsShelves); List<WarehouseGoodsShelves> listAll(@Param("warehouseGoodsShelves") WarehouseGoodsShelves warehouseGoodsShelves); List<WarehouseGoodsShelvesDto> listAll(@Param("warehouseGoodsShelves") WarehouseGoodsShelves warehouseGoodsShelves); } src/main/java/com/ruoyi/warehouse/pojo/DocumentationBorrowManagement.java
@@ -41,6 +41,11 @@ */ @ApiModelProperty(value = "借阅人id") private Long borrowerId; /** * 归还人id */ @ApiModelProperty(value = "归还人id") private Long returnerId; /** * 借阅目的 src/main/java/com/ruoyi/warehouse/service/DocumentClassificationService.java
@@ -16,5 +16,5 @@ boolean deleteByIds(List<Long> ids); List<DocumentClassificationTreeDto> selectDocumentClassificationList(DocumentClassificationDto documentClassificationDto); List<DocumentClassificationTreeDto> selectDocumentClassificationList(); } src/main/java/com/ruoyi/warehouse/service/WarehouseGoodsShelvesService.java
@@ -23,5 +23,5 @@ boolean deleteByIds(List<Long> ids); List<WarehouseGoodsShelves> findList(WarehouseGoodsShelves warehouseGoodsShelves); List<WarehouseGoodsShelvesDto> findList(WarehouseGoodsShelves warehouseGoodsShelves); } src/main/java/com/ruoyi/warehouse/service/impl/DocumentClassificationServiceImpl.java
@@ -48,14 +48,10 @@ } @Override public List<DocumentClassificationTreeDto> selectDocumentClassificationList(DocumentClassificationDto documentClassificationDto) { public List<DocumentClassificationTreeDto> selectDocumentClassificationList() { // 查询根节点(parentId 为 null) LambdaQueryWrapper<DocumentClassification> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.isNull(DocumentClassification::getParentId); if (documentClassificationDto.getCategory() != null && !documentClassificationDto.getCategory().isEmpty()) { queryWrapper.like(DocumentClassification::getCategory, documentClassificationDto.getCategory()); } // 查询根节点列表 List<DocumentClassification> rootList = baseMapper.selectList(queryWrapper); src/main/java/com/ruoyi/warehouse/service/impl/DocumentationBorrowManagementServiceImpl.java
@@ -52,13 +52,12 @@ } @Override public boolean reventdbm(DocumentationBorrowManagement documentationBorrowManagement) { DocumentationBorrowManagement documentationBorrowManagement1 = new DocumentationBorrowManagement(); // 更新借阅记录状态为归还 DocumentationBorrowManagement documentationBorrowManagement1 = documentationBorrowManagementMapper.selectById(documentationBorrowManagement.getId()); documentationBorrowManagement1.setReturnerId(documentationBorrowManagement.getReturnerId()); documentationBorrowManagement1.setBorrowStatus("归还"); documentationBorrowManagement1.setReturnDate(LocalDateTime.now()); documentationBorrowManagementMapper.updateById(documentationBorrowManagement1); documentationBorrowManagementMapper.update(documentationBorrowManagement1,new LambdaQueryWrapper<DocumentationBorrowManagement>().eq(DocumentationBorrowManagement::getId,documentationBorrowManagement.getId())); // 更新文档状态为正常 Documentation documentation = documentationService.getById(documentationBorrowManagement.getDocumentationId()); documentation.setDocStatus("正常"); src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java
@@ -165,7 +165,7 @@ @Override public List<WarehouseGoodsShelves> findList(WarehouseGoodsShelves warehouseGoodsShelves) { public List<WarehouseGoodsShelvesDto> findList(WarehouseGoodsShelves warehouseGoodsShelves) { return warehouseGoodsShelvesMapper.listAll(warehouseGoodsShelves); } src/main/resources/mapper/warehouse/DocumentClassificationMapper.xml
@@ -5,14 +5,14 @@ <mapper namespace="com.ruoyi.warehouse.mapper.DocumentClassificationMapper"> <resultMap id="BaseResultMap" type="com.ruoyi.warehouse.pojo.DocumentClassification"> <id property="id" column="id" jdbcType="BIGINT"/> <result property="category" column="category" jdbcType="VARCHAR"/> <result property="parentId" column="parent_id" jdbcType="BIGINT"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createUser" column="create_user" jdbcType="BIGINT"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateUser" column="update_user" jdbcType="BIGINT"/> <result property="tenantId" column="tenant_id" jdbcType="BIGINT"/> <id property="id" column="id" /> <result property="category" column="category" /> <result property="parentId" column="parent_id" /> <result property="createTime" column="create_time" /> <result property="createUser" column="create_user" /> <result property="updateTime" column="update_time" /> <result property="updateUser" column="update_user" /> <result property="tenantId" column="tenant_id" /> </resultMap> <sql id="Base_Column_List"> src/main/resources/mapper/warehouse/DocumentationBorrowManagementMapper.xml
@@ -28,8 +28,12 @@ <!-- create_time,create_user,update_time,--> <!-- update_user,tenant_id--> <!-- </sql>--> <select id="listPage" resultType="com.ruoyi.warehouse.pojo.DocumentationBorrowManagement"> select *from documentation_borrow_management <select id="listPage" resultType="com.ruoyi.warehouse.dto.DocumentationBorrowManagementDto"> select dbm.*,doc.doc_name,su.nick_name,sur.nick_name as return_nick_name from documentation_borrow_management dbm LEFT JOIN documentation doc on doc.id = dbm.documentation_id LEFT JOIN sys_user su on su.user_id = dbm.borrower_id LEFT JOIN sys_user sur on sur.user_id = dbm.returner_id where 1=1 <if test="documentationBorrowManagement.borrowStatus != null"> and borrow_status = #{documentationBorrowManagement.borrowStatus} @@ -40,6 +44,9 @@ <if test="documentationBorrowManagement.borrowerId != null"> and borrower_id = #{documentationBorrowManagement.borrowerId} </if> <if test="documentationBorrowManagement.returnerId != null"> and returner_id = #{documentationBorrowManagement.returnerId} </if> <if test="documentationBorrowManagement.entryDateStart != null and documentationBorrowManagement.entryDateStart != ''"> and borrow_date >= DATE_FORMAT(#{documentationBorrowManagement.entryDateStart},'%Y-%m-%d') </if> @@ -48,11 +55,12 @@ </if> </select> <select id="export" resultType="com.ruoyi.warehouse.dto.DocumentationBorrowManagementDto"> select dbm.*,doc.doc_name,su.nick_name select dbm.*,doc.doc_name,su.nick_name,sur.nick_name as return_nick_name from documentation_borrow_management dbm LEFT JOIN documentation doc on doc.id = dbm.documentation_id LEFT JOIN sys_user su on su.user_id = dbm.borrower_id where 1=1 LEFT JOIN sys_user sur on sur.user_id = dbm.returner_id where sur.nick_name IS NOT NULL <if test="documentationBorrowManagement.borrowStatus != null"> and borrow_status = #{documentationBorrowManagement.borrowStatus} </if> @@ -70,11 +78,12 @@ </if> </select> <select id="exportrevent" resultType="com.ruoyi.warehouse.dto.ReturnExportDto"> select dbm.*,doc.doc_name,su.nick_name,su.nick_name as return_nick_name select dbm.*,doc.doc_name,su.nick_name,sur.nick_name as return_nick_name from documentation_borrow_management dbm LEFT JOIN documentation doc on doc.id = dbm.documentation_id LEFT JOIN sys_user su on su.user_id = dbm.borrower_id where 1=1 LEFT JOIN sys_user sur on sur.user_id = dbm.returner_id where sur.nick_name IS NOT NULL <if test="documentationBorrowManagement.borrowStatus != null"> and borrow_status = #{documentationBorrowManagement.borrowStatus} </if> src/main/resources/mapper/warehouse/WarehouseGoodsShelvesMapper.xml
@@ -6,10 +6,10 @@ <select id="findList" resultType="com.ruoyi.warehouse.dto.WarehouseGoodsShelvesDto"> SELECT wgsr.*, doc.doc_name, doc.doc_number, wgs.*, w.warehouse_name, wgs.goods_shelves_name, doc.*, dc.category FROM warehouse_goods_shelves_rowcol wgsr LEFT JOIN warehouse_goods_shelves wgs ON wgs.id = wgsr.warehouse_goods_shelves_id @@ -29,8 +29,9 @@ </if> </where> </select> <select id="listAll" resultType="com.ruoyi.warehouse.pojo.WarehouseGoodsShelves"> select * from warehouse_goods_shelves <select id="listAll" resultType="com.ruoyi.warehouse.dto.WarehouseGoodsShelvesDto"> select wgs.*,w.warehouse_name from warehouse_goods_shelves wgs LEFT JOIN warehouse w ON w.id = wgs.warehouse_id <where> 1=1 <if test="warehouseGoodsShelves.goodsShelvesName != null and warehouseGoodsShelves.goodsShelvesName != ''"> src/main/resources/mapper/warehouse/WarehouseGoodsShelvesRowcolMapper.xml
@@ -3,19 +3,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesRowcolMapper"> <select id="findList" resultType="com.ruoyi.warehouse.dto.WarehouseGoodsShelvesRowcolDto"> SELECT doc.doc_name, doc.doc_number, wgsr.*, w.warehouse_name, wgs.goods_shelves_name, doc.*, dc.category FROM warehouse_goods_shelves_rowcol wgsr FROM documentation doc LEFT JOIN warehouse_goods_shelves_rowcol wgsr ON doc.warehouse_goods_shelves_rowcol_id = wgsr.id LEFT JOIN warehouse_goods_shelves wgs ON wgs.id = wgsr.warehouse_goods_shelves_id LEFT JOIN warehouse w ON w.id = wgs.warehouse_id LEFT JOIN documentation doc ON doc.warehouse_goods_shelves_rowcol_id = wgsr.id LEFT JOIN document_classification dc ON doc.document_classification_id = dc.id <where> 1=1 src/main/resources/mapper/warehouse/WarehouseMapper.xml
@@ -4,72 +4,13 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.warehouse.mapper.WarehouseMapper"> <!-- <!– 定义 WarehouseDto 的 resultMap(优化后) –>--> <!-- <resultMap id="WarehouseDtoResultMap" type="com.ruoyi.warehouse.dto.WarehouseDto">--> <!-- <!– 映射 Warehouse 父类的字段(仓库主表信息) –>--> <!-- <id property="id" column="w_id"/> <!– 明确别名,避免与子表id冲突 –>--> <!-- <result property="warehouseName" column="warehouse_name"/>--> <!-- <!– 其他父类字段按需添加,建议统一加表别名前缀 –>--> <!-- <!– 移除 WarehouseDto 中的 goodsShelvesName 字段映射--> <!-- 原因:该字段属于子表 warehouse_goods_shelves,应通过嵌套集合获取,避免数据歧义 –>--> <!-- <!– 映射 WarehouseDto 自身的分类字段(若业务需要关联文档分类) –>--> <!-- <result property="category" column="category"/>--> <!-- <!– 映射嵌套集合:仓库-货架(一对多) –>--> <!-- <collection property="warehouseGoodsShelvesList" ofType="com.ruoyi.warehouse.dto.WarehouseGoodsShelvesDto">--> <!-- <id property="id" column="wgs_id"/> <!– 货架表主键,唯一标识 –>--> <!-- <result property="goodsShelvesName" column="goods_shelves_name"/>--> <!-- <result property="warehouseId" column="w_id"/> <!– 关联仓库的外键,便于反向追溯 –>--> <!-- <!– 其他货架字段按需添加(如创建时间、状态等) –>--> <!-- <!– 映射嵌套集合:货架-行列(一对多) –>--> <!-- <collection property="warehouseGoodsShelvesRowcolList" ofType="com.ruoyi.warehouse.dto.WarehouseGoodsShelvesRowcolDto">--> <!-- <id property="id" column="wgsr_id"/> <!– 行列表自身主键,修正原外键别名导致的歧义 –>--> <!-- <result property="storey" column="storey"/>--> <!-- <result property="arrange" column="arrange"/>--> <!-- <result property="warehouseGoodsShelvesId" column="wgs_id"/> <!– 关联货架的外键 –>--> <!-- <!– 其他行列字段按需添加(如容量、状态等) –>--> <!-- </collection>--> <!-- </collection>--> <!-- </resultMap>--> <!-- <select id="findList" resultMap="WarehouseDtoResultMap">--> <!-- SELECT--> <!-- w.id AS w_id, -- 仓库表id加别名,避免与子表id冲突--> <!-- w.warehouse_name,--> <!-- wgs.id AS wgs_id, -- 货架表id加别名--> <!-- wgs.goods_shelves_name,--> <!-- wgsr.id AS wgsr_id, -- 行列表id加别名(修正原外键别名,明确为主键)--> <!-- wgsr.storey,--> <!-- wgsr.arrange,--> <!-- dc.category--> <!-- FROM warehouse_goods_shelves_rowcol wgsr--> <!-- LEFT JOIN warehouse_goods_shelves wgs ON wgs.id = wgsr.warehouse_goods_shelves_id--> <!-- LEFT JOIN warehouse w ON w.id = wgs.warehouse_id--> <!-- -- 关联文档表和分类表时,若无需文档详情,建议用 EXISTS 优化,避免重复数据--> <!-- LEFT JOIN documentation doc ON doc.warehouse_goods_shelves_rowcol_id = wgsr.id--> <!-- LEFT JOIN document_classification dc ON doc.document_classification_id = dc.id--> <!-- <where>--> <!-- <!– 移除 1=1,MyBatis的where标签会自动处理首个AND –>--> <!-- <if test="warehouse.warehouseName != null and warehouse.warehouseName != ''">--> <!-- AND w.warehouse_name LIKE CONCAT('%', #{warehouse.warehouseName}, '%')--> <!-- </if>--> <!-- <if test="warehouse.id != null">--> <!-- AND w.id = #{warehouse.id}--> <!-- </if>--> <!-- </where>--> <!-- -- 分组去重:避免因多表连接导致的重复数据(核心优化点)--> <!-- GROUP BY w.id, wgs.id, wgsr.id--> <!-- </select>--> <select id="findList" resultType="com.ruoyi.warehouse.dto.WarehouseDto"> SELECT wgsr.*, w.warehouse_name, w.*, wgs.goods_shelves_name, doc.doc_name, doc.doc_number, dc.category FROM warehouse_goods_shelves_rowcol wgsr LEFT JOIN warehouse_goods_shelves wgs ON wgs.id = wgsr.warehouse_goods_shelves_id @@ -93,6 +34,9 @@ <if test="warehouse.warehouseName != null"> and warehouse_name like concat('%',#{warehouse.warehouseName},'%') </if> <if test="warehouse.id != null"> and w.id = #{warehouse.id} </if> </where> </select> </mapper> src/main/resources/mybatis/mybatis-config.xml
@@ -12,8 +12,8 @@ <!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 --> <setting name="defaultExecutorType" value="SIMPLE" /> <!-- 指定 MyBatis 所用日志的具体实现 --> <!-- <setting name="logImpl" value="SLF4J" />--> <setting name="logImpl" value="org.apache.ibatis.logging.stdout.StdOutImpl" /> <setting name="logImpl" value="SLF4J" /> <!-- <setting name="logImpl" value="org.apache.ibatis.logging.stdout.StdOutImpl" />--> <!-- 使用驼峰命名法转换字段 --> <!-- <setting name="mapUnderscoreToCamelCase" value="true"/> --> </settings>