diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java index 14a80bec..6f6e0170 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java @@ -1,8 +1,10 @@ package com.bonus.common.biz.domain; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -30,11 +32,15 @@ public class TreeNode { private String code; - private float num; + /** 原值 */ + @ApiModelProperty(value = "原值") + private BigDecimal buyPrice; - private String modelCode; + /** 实时库存 */ + @ApiModelProperty(value = "实时库存") + private Long storageNum; - private String manageType; + private String remark; @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children = new ArrayList<>(); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java index 828da633..5f55be29 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java @@ -44,11 +44,16 @@ public class PartTypeController extends BaseController @ApiOperation(value = "查询配件类型管理列表") @RequiresPermissions("ma:type:list") @GetMapping("/list") - public TableDataInfo list(PartType partType) + public AjaxResult list(PartType partType) { - startPage(); - List list = partTypeService.selectPartTypeList(partType); - return getDataTable(list); + return partTypeService.selectPartTypeList(partType); + } + + @ApiOperation(value = "配件类型所属上级树") + @RequiresPermissions("ma:type:query") + @GetMapping("/getPartTree") + public AjaxResult getPartTree(PartType dto){ + return partTypeService.getPartTree(dto); } /** @@ -61,7 +66,7 @@ public class PartTypeController extends BaseController @PostMapping("/export") public void export(HttpServletResponse response, PartType partType) { - List list = partTypeService.selectPartTypeList(partType); + List list = partTypeService.getTypeList(partType); ExcelUtil util = new ExcelUtil(PartType.class); util.exportExcel(response, list, "配件类型管理数据"); } @@ -111,8 +116,8 @@ public class PartTypeController extends BaseController @RequiresPermissions("ma:type:remove") @SysLog(title = "配件类型管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除配件类型管理") @DeleteMapping("/{paIds}") - public AjaxResult remove(@PathVariable Long[] paIds) + public AjaxResult remove(@PathVariable Long paId) { - return toAjax(partTypeService.deletePartTypeByPaIds(paIds)); + return partTypeService.deletePartTypeByPaId(paId); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java index 4a029c06..0fe4788b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java @@ -13,24 +13,23 @@ import com.bonus.common.core.web.domain.BaseEntity; * @author xsheng * @date 2024-09-27 */ - - @Data @ToString public class PartType extends BaseEntity { private static final long serialVersionUID = 1L; + private Integer isExport; + /** 类型ID */ private Long paId; /** 类型名称 */ - @Excel(name = "类型名称") + @Excel(name = "名称") @ApiModelProperty(value = "类型名称") private String paName; /** 上级ID */ - @Excel(name = "上级ID") @ApiModelProperty(value = "上级ID") private Long parentId; @@ -38,28 +37,30 @@ public class PartType extends BaseEntity @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") private String status; - /** 实时库存 */ - @Excel(name = "实时库存") - @ApiModelProperty(value = "实时库存") - private Long storageNum; - /** 计量单位ID */ - @Excel(name = "计量单位ID") @ApiModelProperty(value = "计量单位ID") private String unitId; + /** 计量单位名称 */ + @Excel(name = "计量单位") + @ApiModelProperty(value = "计量单位名称") + private String unitName; + /** 原值 */ - @Excel(name = "原值") + @Excel(name = "购置价格(元)") @ApiModelProperty(value = "原值") private BigDecimal buyPrice; + /** 实时库存 */ + @Excel(name = "数量") + @ApiModelProperty(value = "实时库存") + private Long storageNum; + /** 层级 */ - @Excel(name = "层级") @ApiModelProperty(value = "层级") private String level; /** 库存预警数量 */ - @Excel(name = "库存预警数量") @ApiModelProperty(value = "库存预警数量") private Long warnNum; @@ -67,14 +68,14 @@ public class PartType extends BaseEntity private String delFlag; /** 数据所属组织 */ - @Excel(name = "数据所属组织") @ApiModelProperty(value = "数据所属组织") private String companyId; /** 框架年份 */ - @Excel(name = "框架年份") @ApiModelProperty(value = "框架年份") private String year; + @Excel(name = "备注") + private String remark; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java index 30b49e3a..726bcb5a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java @@ -1,6 +1,8 @@ package com.bonus.material.ma.mapper; import java.util.List; + +import com.bonus.common.biz.domain.TreeNode; import com.bonus.material.ma.domain.PartType; /** @@ -25,7 +27,7 @@ public interface PartTypeMapper * @param partType 配件类型管理 * @return 配件类型管理集合 */ - public List selectPartTypeList(PartType partType); + public List selectPartTypeList(PartType partType); /** * 新增配件类型管理 @@ -57,5 +59,19 @@ public interface PartTypeMapper * @param paIds 需要删除的数据主键集合 * @return 结果 */ - public int deletePartTypeByPaIds(Long[] paIds); + public int deletePartTypeByPaIds(Long paIds); + + /** + * 获取配件类型树 + * @param dto + * @return + */ + List getPartTree(PartType dto); + + /** + * 获取配件类型列表 + * @param partType + * @return + */ + List getTypeList(PartType partType); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java index c6bbf25d..a4882ec3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java @@ -1,6 +1,8 @@ package com.bonus.material.ma.service; import java.util.List; + +import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.ma.domain.PartType; /** @@ -25,7 +27,7 @@ public interface IPartTypeService * @param partType 配件类型管理 * @return 配件类型管理集合 */ - public List selectPartTypeList(PartType partType); + public AjaxResult selectPartTypeList(PartType partType); /** * 新增配件类型管理 @@ -49,7 +51,7 @@ public interface IPartTypeService * @param paIds 需要删除的配件类型管理主键集合 * @return 结果 */ - public int deletePartTypeByPaIds(Long[] paIds); + public int deletePartTypeByPaIds(Long paIds); /** * 删除配件类型管理信息 @@ -57,5 +59,19 @@ public interface IPartTypeService * @param paId 配件类型管理主键 * @return 结果 */ - public int deletePartTypeByPaId(Long paId); + public AjaxResult deletePartTypeByPaId(Long paId); + + /** + * 获取配件类型树 + * @param dto + * @return + */ + AjaxResult getPartTree(PartType dto); + + /** + * 导出结果集 + * @param partType + * @return + */ + List getTypeList(PartType partType); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java index d7f45d35..ae3195d9 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java @@ -1,7 +1,15 @@ package com.bonus.material.ma.service.impl; +import java.util.ArrayList; import java.util.List; + +import com.bonus.common.biz.domain.TreeBuild; +import com.bonus.common.biz.domain.TreeNode; +import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.core.web.domain.AjaxResult; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.material.ma.mapper.PartTypeMapper; @@ -15,6 +23,7 @@ import com.bonus.material.ma.service.IPartTypeService; * @date 2024-09-27 */ @Service +@Slf4j public class PartTypeServiceImpl implements IPartTypeService { @Autowired @@ -39,9 +48,22 @@ public class PartTypeServiceImpl implements IPartTypeService * @return 配件类型管理 */ @Override - public List selectPartTypeList(PartType partType) + public AjaxResult selectPartTypeList(PartType partType) { - return partTypeMapper.selectPartTypeList(partType); + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = partTypeMapper.selectPartTypeList(partType); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("配件类型树-查询失败", e); + } + return AjaxResult.success(groupList); } /** @@ -73,13 +95,13 @@ public class PartTypeServiceImpl implements IPartTypeService /** * 批量删除配件类型管理 * - * @param paIds 需要删除的配件类型管理主键 + * @param paId 需要删除的配件类型管理主键 * @return 结果 */ @Override - public int deletePartTypeByPaIds(Long[] paIds) + public int deletePartTypeByPaIds(Long paId) { - return partTypeMapper.deletePartTypeByPaIds(paIds); + return partTypeMapper.deletePartTypeByPaIds(paId); } /** @@ -89,8 +111,47 @@ public class PartTypeServiceImpl implements IPartTypeService * @return 结果 */ @Override - public int deletePartTypeByPaId(Long paId) + public AjaxResult deletePartTypeByPaId(Long paId) { - return partTypeMapper.deletePartTypeByPaId(paId); + int result = partTypeMapper.deletePartTypeByPaId(paId); + if (result > 0) { + return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } + + /** + * 获取配件类型树 + * @param dto + * @return + */ + @Override + public AjaxResult getPartTree(PartType dto) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = partTypeMapper.getPartTree(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("配件所属上级树-查询失败", e); + } + return AjaxResult.success(groupList); + } + + /** + * 获取配件类型列表 + * @param partType + * @return + */ + @Override + public List getTypeList(PartType partType) { + return partTypeMapper.getTypeList(partType); + } + + } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml index b04b4e40..171bed0c 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml @@ -26,28 +26,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select pa_id, pa_name, parent_id, status, storage_num, unit_id, buy_price, level, warn_num, del_flag, create_by, update_by, create_time, update_time, remark, company_id, year from ma_part_type - - - + + + + + + + insert into ma_part_type @@ -112,11 +122,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from ma_part_type where pa_id = #{paId} + update ma_part_type set del_flag = '2' where pa_id = #{paId} - delete from ma_part_type where pa_id in + update ma_part_type set del_flag = '2' where pa_id in #{paId}