From 38ad1741756db5ffba3ce97e5e128008530f9137 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Mon, 14 Oct 2024 15:03:00 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E9=80=BB=E8=BE=91=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E3=80=81=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeController.java | 64 ++++++++----------- .../com/bonus/material/ma/domain/Type.java | 14 ++-- .../bonus/material/ma/mapper/TypeMapper.java | 57 +++++++++-------- .../material/ma/service/ITypeService.java | 49 +++++++------- .../ma/service/impl/TypeServiceImpl.java | 55 ++++++++-------- .../mapper/material/ma/TypeMapper.xml | 21 +++--- 6 files changed, 128 insertions(+), 132 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index d0531686..f6c4456e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -25,94 +25,86 @@ import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.page.TableDataInfo; /** - * 机具类型管理Controller - * - * @author xsheng - * @date 2024-09-27 + * 物资类型管理Controller + * @author syruan */ -@Api(tags = "机具类型管理接口") +@Api(tags = "物资类型管理接口") @RestController @RequestMapping("/ma_type") -public class TypeController extends BaseController -{ +public class TypeController extends BaseController { + @Autowired private ITypeService typeService; /** - * 查询机具类型管理列表 + * 查询物资类型管理列表 */ - @ApiOperation(value = "查询机具类型管理列表") + @ApiOperation(value = "查询物资类型管理列表") @RequiresPermissions("ma:type:list") @GetMapping("/list") - public TableDataInfo list(Type type) - { + public TableDataInfo list(Type type) { startPage(); List list = typeService.selectTypeList(type); return getDataTable(list); } /** - * 导出机具类型管理列表 + * 导出物资类型管理列表 */ - @ApiOperation(value = "导出机具类型管理列表") + @ApiOperation(value = "导出物资类型管理列表") @PreventRepeatSubmit @RequiresPermissions("ma:type:export") - @SysLog(title = "机具类型管理", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出机具类型管理") + @SysLog(title = "物资类型管理", businessType = OperaType.EXPORT, module = "仓储管理->导出物资类型") @PostMapping("/export") - public void export(HttpServletResponse response, Type type) - { + public void export(HttpServletResponse response, Type type) { List list = typeService.selectTypeList(type); ExcelUtil util = new ExcelUtil(Type.class); - util.exportExcel(response, list, "机具类型管理数据"); + util.exportExcel(response, list, "物资类型管理数据"); } /** - * 获取机具类型管理详细信息 + * 获取物资类型管理详细信息 */ - @ApiOperation(value = "获取机具类型管理详细信息") + @ApiOperation(value = "获取物资类型管理详细信息") @RequiresPermissions("ma:type:query") @GetMapping(value = "/{typeId}") - public AjaxResult getInfo(@PathVariable("typeId") Long typeId) - { + public AjaxResult getInfo(@PathVariable("typeId") Long typeId) { return success(typeService.selectTypeByTypeId(typeId)); } /** - * 新增机具类型管理 + * 新增物资类型管理 */ - @ApiOperation(value = "新增机具类型管理") + @ApiOperation(value = "新增物资类型管理") @PreventRepeatSubmit @RequiresPermissions("ma:type:add") - @SysLog(title = "机具类型管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增机具类型管理") + @SysLog(title = "物资类型管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增物资类型") @PostMapping - public AjaxResult add(@RequestBody Type type) - { + public AjaxResult add(@RequestBody Type type) { return toAjax(typeService.insertType(type)); } /** - * 修改机具类型管理 + * 修改物资类型管理 */ - @ApiOperation(value = "修改机具类型管理") + @ApiOperation(value = "修改物资类型管理") @PreventRepeatSubmit @RequiresPermissions("ma:type:edit") - @SysLog(title = "机具类型管理", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改机具类型管理") + @SysLog(title = "物资类型管理", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改物资类型") @PutMapping - public AjaxResult edit(@RequestBody Type type) - { + public AjaxResult edit(@RequestBody Type type) { return toAjax(typeService.updateType(type)); } /** - * 删除机具类型管理 + * 删除物资类型管理 */ - @ApiOperation(value = "删除机具类型管理") + @ApiOperation(value = "删除物资类型管理") @PreventRepeatSubmit @RequiresPermissions("ma:type:remove") - @SysLog(title = "机具类型管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除机具类型管理") + @SysLog(title = "物资类型管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除物资类型") @DeleteMapping("/{typeIds}") - public AjaxResult remove(@PathVariable Long[] typeIds) - { + public AjaxResult remove(@PathVariable Long[] typeIds) { return toAjax(typeService.deleteTypeByTypeIds(typeIds)); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java index 9a9c07ce..12275cbb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java @@ -6,21 +6,19 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; /** - * 机具类型管理对象 ma_type - * - * @author xsheng - * @date 2024-09-27 + * 物资类型对象 ma_type + * @author syruan */ - - +@EqualsAndHashCode(callSuper = false) @Data @ToString -public class Type extends BaseEntity -{ +public class Type extends BaseEntity { + private static final long serialVersionUID = 1L; /** 类型ID */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index 68b10f46..fe0f2947 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -2,60 +2,67 @@ package com.bonus.material.ma.mapper; import java.util.List; import com.bonus.material.ma.domain.Type; +import org.apache.ibatis.annotations.Mapper; /** - * 机具类型管理Mapper接口 - * - * @author xsheng - * @date 2024-09-27 + * 物资类型Mapper接口 + * @author syruan */ -public interface TypeMapper -{ +@Mapper +public interface TypeMapper { /** - * 查询机具类型管理 + * 查询物资类型 * - * @param typeId 机具类型管理主键 - * @return 机具类型管理 + * @param typeId 物资类型主键 + * @return 物资类型 */ - public Type selectTypeByTypeId(Long typeId); + Type selectTypeByTypeId(Long typeId); /** - * 查询机具类型管理列表 + * 查询物资类型列表 * - * @param type 机具类型管理 - * @return 机具类型管理集合 + * @param type 物资类型 + * @return 物资类型集合 */ - public List selectTypeList(Type type); + List selectTypeList(Type type); /** - * 新增机具类型管理 + * 新增物资类型 * - * @param type 机具类型管理 + * @param type 物资类型 * @return 结果 */ - public int insertType(Type type); + int insertType(Type type); /** - * 修改机具类型管理 + * 修改物资类型 * - * @param type 机具类型管理 + * @param type 物资类型 * @return 结果 */ - public int updateType(Type type); + int updateType(Type type); /** - * 删除机具类型管理 + * 删除物资类型 -- 真实删除 * - * @param typeId 机具类型管理主键 + * @param typeId 物资类型主键 * @return 结果 */ - public int deleteTypeByTypeId(Long typeId); + int deleteTypeByTypeId(Long typeId); /** - * 批量删除机具类型管理 + * 删除物资类型 -- 逻辑删除 + * + * @param typeId 物资类型主键 + * @return 结果 + */ + int logicDeleteTypeByTypeId(Long typeId); + + /** + * 批量删除物资类型 -- 逻辑删除 * * @param typeIds 需要删除的数据主键集合 * @return 结果 */ - public int deleteTypeByTypeIds(Long[] typeIds); + int logicDeleteTypeByTypeIds(Long[] typeIds); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 3420fdf5..1b48be9e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -4,58 +4,55 @@ import java.util.List; import com.bonus.material.ma.domain.Type; /** - * 机具类型管理Service接口 - * - * @author xsheng - * @date 2024-09-27 + * 物资类型Service接口 + * @author syruan */ -public interface ITypeService -{ +public interface ITypeService { /** - * 查询机具类型管理 + * 查询物资类型 * - * @param typeId 机具类型管理主键 - * @return 机具类型管理 + * @param typeId 物资类型主键 + * @return 物资类型 */ - public Type selectTypeByTypeId(Long typeId); + Type selectTypeByTypeId(Long typeId); /** - * 查询机具类型管理列表 + * 查询物资类型列表 * - * @param type 机具类型管理 - * @return 机具类型管理集合 + * @param type 物资类型 + * @return 物资类型集合 */ - public List selectTypeList(Type type); + List selectTypeList(Type type); /** - * 新增机具类型管理 + * 新增物资类型 * - * @param type 机具类型管理 + * @param type 物资类型 * @return 结果 */ - public int insertType(Type type); + int insertType(Type type); /** - * 修改机具类型管理 + * 修改物资类型 * - * @param type 机具类型管理 + * @param type 物资类型 * @return 结果 */ - public int updateType(Type type); + int updateType(Type type); /** - * 批量删除机具类型管理 + * 批量删除物资类型 * - * @param typeIds 需要删除的机具类型管理主键集合 + * @param typeIds 需要删除的物资类型主键集合 * @return 结果 */ - public int deleteTypeByTypeIds(Long[] typeIds); + int deleteTypeByTypeIds(Long[] typeIds); /** - * 删除机具类型管理信息 + * 删除物资类型信息 * - * @param typeId 机具类型管理主键 + * @param typeId 物资类型主键 * @return 结果 */ - public int deleteTypeByTypeId(Long typeId); + int deleteTypeByTypeId(Long typeId); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 7dc5cb9f..67b37bf6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -8,35 +8,34 @@ import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.service.ITypeService; +import javax.annotation.Resource; + /** - * 机具类型管理Service业务层处理 - * - * @author xsheng - * @date 2024-09-27 + * 物资类型管理Service业务层实现 + * @author syruan */ @Service -public class TypeServiceImpl implements ITypeService -{ - @Autowired +public class TypeServiceImpl implements ITypeService { + + @Resource private TypeMapper typeMapper; /** - * 查询机具类型管理 + * 查询物资类型管理 * - * @param typeId 机具类型管理主键 - * @return 机具类型管理 + * @param typeId 物资类型管理主键 + * @return 物资类型管理 */ @Override - public Type selectTypeByTypeId(Long typeId) - { + public Type selectTypeByTypeId(Long typeId) { return typeMapper.selectTypeByTypeId(typeId); } /** - * 查询机具类型管理列表 + * 查询物资类型管理列表 * - * @param type 机具类型管理 - * @return 机具类型管理 + * @param type 物资类型管理 + * @return 物资类型管理 */ @Override public List selectTypeList(Type type) @@ -45,22 +44,21 @@ public class TypeServiceImpl implements ITypeService } /** - * 新增机具类型管理 + * 新增物资类型管理 * - * @param type 机具类型管理 + * @param type 物资类型管理 * @return 结果 */ @Override - public int insertType(Type type) - { + public int insertType(Type type) { type.setCreateTime(DateUtils.getNowDate()); return typeMapper.insertType(type); } /** - * 修改机具类型管理 + * 修改物资类型管理 * - * @param type 机具类型管理 + * @param type 物资类型管理 * @return 结果 */ @Override @@ -71,26 +69,25 @@ public class TypeServiceImpl implements ITypeService } /** - * 批量删除机具类型管理 + * 批量删除物资类型管理 * - * @param typeIds 需要删除的机具类型管理主键 + * @param typeIds 需要删除的物资类型管理主键 * @return 结果 */ @Override public int deleteTypeByTypeIds(Long[] typeIds) { - return typeMapper.deleteTypeByTypeIds(typeIds); + return typeMapper.logicDeleteTypeByTypeIds(typeIds); } /** - * 删除机具类型管理信息 + * 删除物资类型 * - * @param typeId 机具类型管理主键 + * @param typeId 物资类型管理主键 * @return 结果 */ @Override - public int deleteTypeByTypeId(Long typeId) - { - return typeMapper.deleteTypeByTypeId(typeId); + public int deleteTypeByTypeId(Long typeId) { + return typeMapper.logicDeleteTypeByTypeId(typeId); } } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 8d0ee58c..1eb51fec 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -3,6 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + @@ -35,7 +36,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select type_id, type_name, parent_id, storage_num, type_code, model_code, unit_id, manage_type, lease_price, eff_time, rent_price, buy_price, pay_ratio, level, rated_load, test_load, holding_time, warn_num, del_flag, create_by, create_time, update_by, update_time, is_plan, is_ancuo, remark, fac_model, intelligent_code from ma_type + select + type_id, type_name, parent_id, storage_num, type_code, model_code, unit_id, manage_type, lease_price, + eff_time, rent_price, buy_price, pay_ratio, level, rated_load, test_load, holding_time, warn_num, + create_by, create_time, update_by, update_time, is_plan,is_ancuo, remark, fac_model, intelligent_code + from ma_type @@ -90,7 +96,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" test_load, holding_time, warn_num, - del_flag, create_by, create_time, update_by, @@ -119,7 +124,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{testLoad}, #{holdingTime}, #{warnNum}, - #{delFlag}, #{createBy}, #{createTime}, #{updateBy}, @@ -152,9 +156,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" test_load = #{testLoad}, holding_time = #{holdingTime}, warn_num = #{warnNum}, - del_flag = #{delFlag}, - create_by = #{createBy}, - create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, is_plan = #{isPlan}, @@ -170,10 +171,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from ma_type where type_id = #{typeId} - - delete from ma_type where type_id in + + update ma_type set del_flag = 2 where type_id in #{typeId} + + + update ma_type set del_flag = 2 where type_id = #{typeId,jdbcType=BIGINT} + \ No newline at end of file From e5703fa5fc4c46d8f5d5fd6e8a70558be7428cca Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Mon, 14 Oct 2024 16:27:16 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E6=96=B0=E5=A2=9Etree=E6=A0=91=E5=BD=A2?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeController.java | 27 +++--- .../bonus/material/ma/domain/TreeSelect.java | 51 +++++++++++ .../com/bonus/material/ma/domain/Type.java | 7 ++ .../bonus/material/ma/mapper/TypeMapper.java | 7 ++ .../material/ma/service/ITypeService.java | 12 +++ .../ma/service/impl/TypeServiceImpl.java | 84 +++++++++++++++++-- .../mapper/material/ma/TypeMapper.xml | 5 ++ 7 files changed, 177 insertions(+), 16 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TreeSelect.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index f6c4456e..8b18c1aa 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -4,17 +4,11 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.ma.domain.TreeSelect; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.bonus.common.log.annotation.SysLog; import com.bonus.common.security.annotation.RequiresPermissions; import com.bonus.material.ma.domain.Type; @@ -48,6 +42,17 @@ public class TypeController extends BaseController { return getDataTable(list); } + /** + * 物资类型下拉树 + */ + @ApiOperation(value = "物资类型下拉树") + @RequiresPermissions("ma:type:list") + @GetMapping("/getMaTypeTreeSelect") + public AjaxResult getMaTypeTreeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) { + List maTypeList = typeService.getMaTypeTree(typeName, parentId); + return AjaxResult.success(maTypeList); + } + /** * 导出物资类型管理列表 */ @@ -78,7 +83,7 @@ public class TypeController extends BaseController { @ApiOperation(value = "新增物资类型管理") @PreventRepeatSubmit @RequiresPermissions("ma:type:add") - @SysLog(title = "物资类型管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增物资类型") + @SysLog(title = "物资类型管理", businessType = OperaType.INSERT, module = "仓储管理->新增物资类型") @PostMapping public AjaxResult add(@RequestBody Type type) { return toAjax(typeService.insertType(type)); @@ -90,7 +95,7 @@ public class TypeController extends BaseController { @ApiOperation(value = "修改物资类型管理") @PreventRepeatSubmit @RequiresPermissions("ma:type:edit") - @SysLog(title = "物资类型管理", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改物资类型") + @SysLog(title = "物资类型管理", businessType = OperaType.UPDATE, module = "仓储管理->修改物资类型") @PutMapping public AjaxResult edit(@RequestBody Type type) { return toAjax(typeService.updateType(type)); @@ -102,7 +107,7 @@ public class TypeController extends BaseController { @ApiOperation(value = "删除物资类型管理") @PreventRepeatSubmit @RequiresPermissions("ma:type:remove") - @SysLog(title = "物资类型管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除物资类型") + @SysLog(title = "物资类型管理", businessType = OperaType.DELETE, module = "仓储管理->删除物资类型") @DeleteMapping("/{typeIds}") public AjaxResult remove(@PathVariable Long[] typeIds) { return toAjax(typeService.deleteTypeByTypeIds(typeIds)); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TreeSelect.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TreeSelect.java new file mode 100644 index 00000000..e3c3a14c --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TreeSelect.java @@ -0,0 +1,51 @@ +package com.bonus.material.ma.domain; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * TreeSelect树结构实体类 + * @author syruan + */ +@Data +public class TreeSelect implements Serializable { + + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private Long id; + + /** 节点名称 */ + private String label; + + /** 节点级别 */ + private Integer level; + + /** 父节点id */ + private Long parentId; + + /** 公司id */ + private String companyId; + + /** 子节点集合 */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public TreeSelect() { + + } + + public TreeSelect(Type maType) { + this.parentId = maType.getParentId(); + this.level = Integer.valueOf(maType.getLevel()); + this.id = maType.getTypeId(); + this.label = maType.getTypeName(); + this.companyId = String.valueOf(maType.getUnitId()); + this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java index 12275cbb..6de6e0c2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java @@ -1,9 +1,13 @@ package com.bonus.material.ma.domain; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; import com.bonus.common.core.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -132,5 +136,8 @@ public class Type extends BaseEntity { @ApiModelProperty(value = "推送智慧工程定义的门类分类机具编码") private String intelligentCode; + /** 子节点 */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children = new ArrayList<>(); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index fe0f2947..b7c9229b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -3,6 +3,7 @@ package com.bonus.material.ma.mapper; import java.util.List; import com.bonus.material.ma.domain.Type; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 物资类型Mapper接口 @@ -18,6 +19,12 @@ public interface TypeMapper { */ Type selectTypeByTypeId(Long typeId); + /** + * 物资类型树形结构 + * @param level 排除层级 + */ + List selectMaTypeTree(@Param("level") Integer level); + /** * 查询物资类型列表 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 1b48be9e..5b1fd50f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -1,6 +1,8 @@ package com.bonus.material.ma.service; import java.util.List; + +import com.bonus.material.ma.domain.TreeSelect; import com.bonus.material.ma.domain.Type; /** @@ -55,4 +57,14 @@ public interface ITypeService { * @return 结果 */ int deleteTypeByTypeId(Long typeId); + + List getMaTypeTree(String typeName, String parentId); + + /** + * 构建前端所需要树结构 + * + * @param maTypeList 状态列表 + * @return 树结构列表 + */ + List buildMaTypeTree(List maTypeList); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 67b37bf6..08038f88 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -1,8 +1,12 @@ package com.bonus.material.ma.service.impl; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; + +import com.bonus.material.ma.domain.TreeSelect; import com.bonus.common.core.utils.DateUtils; -import org.springframework.beans.factory.annotation.Autowired; +import com.bonus.common.core.utils.StringUtils; import org.springframework.stereotype.Service; import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.ma.domain.Type; @@ -17,14 +21,18 @@ import javax.annotation.Resource; @Service public class TypeServiceImpl implements ITypeService { + /** + * 物资类型管理树最小级别 + */ + public static final Integer TYPE_MIN_LEVEL = 4; + @Resource private TypeMapper typeMapper; /** - * 查询物资类型管理 + * 查询物资类型 -- 根据id * * @param typeId 物资类型管理主键 - * @return 物资类型管理 */ @Override public Type selectTypeByTypeId(Long typeId) { @@ -62,8 +70,7 @@ public class TypeServiceImpl implements ITypeService { * @return 结果 */ @Override - public int updateType(Type type) - { + public int updateType(Type type) { type.setUpdateTime(DateUtils.getNowDate()); return typeMapper.updateType(type); } @@ -90,4 +97,71 @@ public class TypeServiceImpl implements ITypeService { public int deleteTypeByTypeId(Long typeId) { return typeMapper.logicDeleteTypeByTypeId(typeId); } + + + @Override + public List getMaTypeTree(String typeName, String parentId) { + List maTypes = typeMapper.selectMaTypeTree(TYPE_MIN_LEVEL); + List treeSelectList = buildMaTypeTree(maTypes); + //如果没有查询到那么返回空 + return treeSelectList.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + /** + * 构建前端所需要树结构 + * + * @param maTypeList 部门列表 + * @return 树结构列表 + */ + @Override + public List buildMaTypeTree(List maTypeList) { + List returnList = new ArrayList(); + List tempList = maTypeList.stream().map(Type::getTypeId).collect(Collectors.toList()); + for (Type maType : maTypeList) { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(maType.getParentId())) { + recursionFn(maTypeList, maType); + returnList.add(maType); + } + } + if (returnList.isEmpty()) { + returnList = maTypeList; + } + return returnList; + } + + /** + * 递归列表 + */ + private void recursionFn(List list, Type t) { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (Type tChild : childList) { + if (hasChild(list, tChild)) { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, Type t) { + List tlist = new ArrayList(); + for (Type n : list) { + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getTypeId().longValue()) { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, Type t) { + return !getChildList(list, t).isEmpty(); + } + } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 1eb51fec..26a9449a 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -181,4 +181,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update ma_type set del_flag = 2 where type_id = #{typeId,jdbcType=BIGINT} + + \ No newline at end of file From 40cb13324d530a0912a349f6a501e8a842759283 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Mon, 14 Oct 2024 17:20:44 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/material/ma/TypeMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 26a9449a..88d537fa 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and type_name like concat('%', #{typeName}, '%') - and parent_id = #{parentId} + and parent_id = #{parentId} and storage_num = #{storageNum} and type_code = #{typeCode} and model_code = #{modelCode} From 09c8b9f1010b23ce8ac39f4d4bb0d980722b6d41 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Mon, 14 Oct 2024 18:07:00 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E4=BC=98=E5=8C=96=E9=80=92=E5=BD=92?= =?UTF-8?q?=E9=80=BB=E8=BE=91,=E6=96=B0=E5=A2=9Evo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/common/biz}/domain/TreeSelect.java | 16 +++++----- .../ma/controller/TypeController.java | 6 ++-- .../material/ma/service/ITypeService.java | 2 +- .../ma/service/impl/TypeServiceImpl.java | 31 ++++++++++++++----- .../bonus/material/ma/vo/MaTypeListVo.java | 26 ++++++++++++++++ .../mapper/material/ma/TypeMapper.xml | 6 ++-- 6 files changed, 63 insertions(+), 24 deletions(-) rename {bonus-modules/bonus-material/src/main/java/com/bonus/material/ma => bonus-common-biz/src/main/java/com/bonus/common/biz}/domain/TreeSelect.java (60%) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeListVo.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TreeSelect.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java similarity index 60% rename from bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TreeSelect.java rename to bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java index e3c3a14c..31c0eaad 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TreeSelect.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java @@ -1,11 +1,10 @@ -package com.bonus.material.ma.domain; +package com.bonus.common.biz.domain; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import java.io.Serializable; import java.util.List; -import java.util.stream.Collectors; /** * TreeSelect树结构实体类 @@ -39,13 +38,12 @@ public class TreeSelect implements Serializable { } - public TreeSelect(Type maType) { - this.parentId = maType.getParentId(); - this.level = Integer.valueOf(maType.getLevel()); - this.id = maType.getTypeId(); - this.label = maType.getTypeName(); - this.companyId = String.valueOf(maType.getUnitId()); - this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + public TreeSelect(Long id, String label, Integer level, Long parentId, List children) { + this.id = id; + this.label = label; + this.level = level; + this.parentId = parentId; + this.children = children; } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index 8b18c1aa..ff9b3886 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -1,13 +1,13 @@ package com.bonus.material.ma.controller; import java.util.List; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; -import com.bonus.material.ma.domain.TreeSelect; +import com.bonus.common.biz.domain.TreeSelect; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.bonus.common.log.annotation.SysLog; import com.bonus.common.security.annotation.RequiresPermissions; @@ -27,7 +27,7 @@ import com.bonus.common.core.web.page.TableDataInfo; @RequestMapping("/ma_type") public class TypeController extends BaseController { - @Autowired + @Resource private ITypeService typeService; /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 5b1fd50f..6bf2a072 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -2,7 +2,7 @@ package com.bonus.material.ma.service; import java.util.List; -import com.bonus.material.ma.domain.TreeSelect; +import com.bonus.common.biz.domain.TreeSelect; import com.bonus.material.ma.domain.Type; /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 08038f88..9503c198 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -2,9 +2,10 @@ package com.bonus.material.ma.service.impl; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; -import com.bonus.material.ma.domain.TreeSelect; +import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; import org.springframework.stereotype.Service; @@ -46,8 +47,11 @@ public class TypeServiceImpl implements ITypeService { * @return 物资类型管理 */ @Override - public List selectTypeList(Type type) - { + public List selectTypeList(Type type) { + // 如果是顶级节点,则查询所有子节点 + if (type != null && "0".equals(type.getLevel())) { + type.setLevel(null); + } return typeMapper.selectTypeList(type); } @@ -82,8 +86,7 @@ public class TypeServiceImpl implements ITypeService { * @return 结果 */ @Override - public int deleteTypeByTypeIds(Long[] typeIds) - { + public int deleteTypeByTypeIds(Long[] typeIds) { return typeMapper.logicDeleteTypeByTypeIds(typeIds); } @@ -103,8 +106,20 @@ public class TypeServiceImpl implements ITypeService { public List getMaTypeTree(String typeName, String parentId) { List maTypes = typeMapper.selectMaTypeTree(TYPE_MIN_LEVEL); List treeSelectList = buildMaTypeTree(maTypes); - //如果没有查询到那么返回空 - return treeSelectList.stream().map(TreeSelect::new).collect(Collectors.toList()); + + // 如果没有查询到那么返回空 + return treeSelectList.stream() + .filter(Objects::nonNull) + .map(this::convertToTreeSelect) + .collect(Collectors.toList()); + } + + private TreeSelect convertToTreeSelect(Type type) { + List children = type.getChildren().stream() + .filter(Objects::nonNull) + .map(this::convertToTreeSelect) + .collect(Collectors.toList()); + return new TreeSelect(type.getTypeId(), type.getTypeName(),Integer.valueOf(type.getLevel()),type.getParentId(), children); } /** @@ -148,7 +163,7 @@ public class TypeServiceImpl implements ITypeService { * 得到子节点列表 */ private List getChildList(List list, Type t) { - List tlist = new ArrayList(); + List tlist = new ArrayList<>(); for (Type n : list) { if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getTypeId().longValue()) { tlist.add(n); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeListVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeListVo.java new file mode 100644 index 00000000..377c8c22 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeListVo.java @@ -0,0 +1,26 @@ +package com.bonus.material.ma.vo; + +import com.bonus.material.ma.domain.Type; +import lombok.Getter; +import lombok.Setter; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.ma.vo + * @CreateTime: 2024-10-14 17:47 + * @Description: 物资类型列表展示VO + */ +@Getter +@Setter +public class MaTypeListVo extends Type { + + private String parentOneLevelName; + + private String parentTwoLevelName; + + private String parentThreeLevelName; + + private String parentFourLevelName; + +} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 88d537fa..094ed06d 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and rent_price = #{rentPrice} and buy_price = #{buyPrice} and pay_ratio = #{payRatio} - and level = #{level} + and `level` = #{level} and rated_load = #{ratedLoad} and test_load = #{testLoad} and holding_time = #{holdingTime} @@ -91,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" rent_price, buy_price, pay_ratio, - level, + `level`, rated_load, test_load, holding_time, @@ -151,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" rent_price = #{rentPrice}, buy_price = #{buyPrice}, pay_ratio = #{payRatio}, - level = #{level}, + `level` = #{level}, rated_load = #{ratedLoad}, test_load = #{testLoad}, holding_time = #{holdingTime}, From 5e999139a9a7fd3798b6474d7d63aa69d7cf4cce Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Mon, 14 Oct 2024 18:34:30 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E6=96=B0=E5=A2=9E=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=88=B6=E7=BA=A7=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/common/biz/domain/TreeSelect.java | 2 +- .../ma/controller/TypeController.java | 5 ++- .../bonus/material/ma/mapper/TypeMapper.java | 11 +++++ .../material/ma/service/ITypeService.java | 3 ++ .../ma/service/impl/TypeServiceImpl.java | 16 ++++++++ .../mapper/material/ma/TypeMapper.xml | 41 +++++++++++++++++++ 6 files changed, 75 insertions(+), 3 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java index 31c0eaad..fc39260b 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java @@ -13,7 +13,7 @@ import java.util.List; @Data public class TreeSelect implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 469203039368157600L; /** 节点ID */ private Long id; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index ff9b3886..b7195b9c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.common.biz.domain.TreeSelect; +import com.bonus.material.ma.vo.MaTypeListVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -36,9 +37,9 @@ public class TypeController extends BaseController { @ApiOperation(value = "查询物资类型管理列表") @RequiresPermissions("ma:type:list") @GetMapping("/list") - public TableDataInfo list(Type type) { + public TableDataInfo list(MaTypeListVo type) { startPage(); - List list = typeService.selectTypeList(type); + List list = typeService.selectTypeListAndParent(type); return getDataTable(list); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index b7c9229b..835c6cb1 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -2,6 +2,7 @@ package com.bonus.material.ma.mapper; import java.util.List; import com.bonus.material.ma.domain.Type; +import com.bonus.material.ma.vo.MaTypeListVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -33,6 +34,16 @@ public interface TypeMapper { */ List selectTypeList(Type type); + + /** + * 查询物资类型列表 -- 并且查询当前节点的父级节点名称 + * + * @param typeListVo 物资类型 + * @return 物资类型集合 + */ + List selectTypeListAndParent(Type typeListVo); + + /** * 新增物资类型 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 6bf2a072..fd03bea3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -4,6 +4,7 @@ import java.util.List; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.material.ma.domain.Type; +import com.bonus.material.ma.vo.MaTypeListVo; /** * 物资类型Service接口 @@ -26,6 +27,8 @@ public interface ITypeService { */ List selectTypeList(Type type); + List selectTypeListAndParent(Type type); + /** * 新增物资类型 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 9503c198..078f9299 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -8,6 +8,7 @@ import java.util.stream.Collectors; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; +import com.bonus.material.ma.vo.MaTypeListVo; import org.springframework.stereotype.Service; import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.ma.domain.Type; @@ -55,6 +56,21 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.selectTypeList(type); } + /** + * 查询物资类型管理列表 -- 并获取父级信息 + * + * @param type 物资类型管理 + * @return 物资类型管理 + */ + @Override + public List selectTypeListAndParent(Type type) { + // 如果是顶级节点,则查询所有子节点 + if (type != null && "0".equals(type.getLevel())) { + type.setLevel(null); + } + return typeMapper.selectTypeListAndParent(type); + } + /** * 新增物资类型管理 * diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 094ed06d..2576399c 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -186,4 +186,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where del_flag = 0 and level != #{level} + + \ No newline at end of file From bd1716a2d3ddf4190590d06894a5f42d9d784b9a Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Tue, 15 Oct 2024 13:26:33 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8,DataCode=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/common/biz/enums/DataCodeEnum.java | 26 ++++++++++++++ .../bonus/common/biz/enums/HttpCodeEnum.java | 19 +++++----- .../ma/controller/TypeController.java | 10 +++--- .../ma/controller/TypeKeeperController.java | 31 +++++++--------- .../bonus/material/ma/domain/TypeKeeper.java | 23 +++++++----- .../material/ma/mapper/PartRepairMapper.java | 5 ++- .../material/ma/mapper/TypeKeeperMapper.java | 20 +++++------ .../ma/service/ITypeKeeperService.java | 18 ++++------ .../service/impl/TypeKeeperServiceImpl.java | 19 ++++------ .../ma/service/impl/TypeServiceImpl.java | 17 +++++++-- .../controller/WhHouseInfoController.java | 35 +++++++++++-------- .../warehouse/domain/WhHouseInfo.java | 29 +++++++++------ .../warehouse/mapper/WhHouseInfoMapper.java | 2 +- .../service/IWhHouseInfoService.java | 15 ++++---- .../service/impl/WhHouseInfoServiceImpl.java | 3 +- .../mapper/material/ma/TypeKeeperMapper.xml | 3 +- .../mapper/material/ma/TypeMapper.xml | 2 +- .../material/warehouse/WhHouseInfoMapper.xml | 15 ++++++-- 18 files changed, 168 insertions(+), 124 deletions(-) create mode 100644 bonus-common-biz/src/main/java/com/bonus/common/biz/enums/DataCodeEnum.java diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/DataCodeEnum.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/DataCodeEnum.java new file mode 100644 index 00000000..6b1aab14 --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/DataCodeEnum.java @@ -0,0 +1,26 @@ +package com.bonus.common.biz.enums; + +import lombok.Getter; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.common.biz.enums + * @CreateTime: 2024-10-15 10:28 + * @Description: 数据状态枚举类 + */ +@Getter +public enum DataCodeEnum { + + NORMAL(0, "正常"), + DELETED(2, "已删除"); + + private final int code; + private final String msg; + + DataCodeEnum(int code, String msg) { + this.code = code; + this.msg = msg; + } + +} diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java index df53128d..7032eee0 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java @@ -1,5 +1,12 @@ package com.bonus.common.biz.enums; +import lombok.Getter; + +/** + * @author bonus + */ + +@Getter public enum HttpCodeEnum { // 成功 SUCCESS(200, "操作成功"), @@ -20,19 +27,13 @@ public enum HttpCodeEnum { NICKNAME_EXIST(512, "昵称已存在"), LOGIN_ERROR(505, "用户名或密码错误"), REPEATE_ERROR(600, "不允许重复提交,请稍候再试"); - int code; - String msg; + + private final int code; + private final String msg; HttpCodeEnum(int code, String errorMessage) { this.code = code; this.msg = errorMessage; } - public int getCode() { - return code; - } - - public String getMsg() { - return msg; - } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index b7195b9c..ab0e2f54 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -57,7 +57,7 @@ public class TypeController extends BaseController { /** * 导出物资类型管理列表 */ - @ApiOperation(value = "导出物资类型管理列表") + @ApiOperation(value = "导出物资类型列表") @PreventRepeatSubmit @RequiresPermissions("ma:type:export") @SysLog(title = "物资类型管理", businessType = OperaType.EXPORT, module = "仓储管理->导出物资类型") @@ -71,7 +71,7 @@ public class TypeController extends BaseController { /** * 获取物资类型管理详细信息 */ - @ApiOperation(value = "获取物资类型管理详细信息") + @ApiOperation(value = "获取物资类型详细信息") @RequiresPermissions("ma:type:query") @GetMapping(value = "/{typeId}") public AjaxResult getInfo(@PathVariable("typeId") Long typeId) { @@ -81,7 +81,7 @@ public class TypeController extends BaseController { /** * 新增物资类型管理 */ - @ApiOperation(value = "新增物资类型管理") + @ApiOperation(value = "新增物资类型") @PreventRepeatSubmit @RequiresPermissions("ma:type:add") @SysLog(title = "物资类型管理", businessType = OperaType.INSERT, module = "仓储管理->新增物资类型") @@ -93,7 +93,7 @@ public class TypeController extends BaseController { /** * 修改物资类型管理 */ - @ApiOperation(value = "修改物资类型管理") + @ApiOperation(value = "修改物资类型") @PreventRepeatSubmit @RequiresPermissions("ma:type:edit") @SysLog(title = "物资类型管理", businessType = OperaType.UPDATE, module = "仓储管理->修改物资类型") @@ -105,7 +105,7 @@ public class TypeController extends BaseController { /** * 删除物资类型管理 */ - @ApiOperation(value = "删除物资类型管理") + @ApiOperation(value = "删除物资类型") @PreventRepeatSubmit @RequiresPermissions("ma:type:remove") @SysLog(title = "物资类型管理", businessType = OperaType.DELETE, module = "仓储管理->删除物资类型") diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeKeeperController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeKeeperController.java index d719aff8..b328de4f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeKeeperController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeKeeperController.java @@ -26,15 +26,13 @@ import com.bonus.common.core.web.page.TableDataInfo; /** * 库管员配置Controller - * - * @author xsheng - * @date 2024-09-27 + * @author bonus */ @Api(tags = "库管员配置接口") @RestController @RequestMapping("/ma_type_keeper") -public class TypeKeeperController extends BaseController -{ +public class TypeKeeperController extends BaseController { + @Autowired private ITypeKeeperService typeKeeperService; @@ -44,8 +42,7 @@ public class TypeKeeperController extends BaseController @ApiOperation(value = "查询库管员配置列表") @RequiresPermissions("ma:keeper:list") @GetMapping("/list") - public TableDataInfo list(TypeKeeper typeKeeper) - { + public TableDataInfo list(TypeKeeper typeKeeper) { startPage(); List list = typeKeeperService.selectTypeKeeperList(typeKeeper); return getDataTable(list); @@ -57,10 +54,9 @@ public class TypeKeeperController extends BaseController @ApiOperation(value = "导出库管员配置列表") @PreventRepeatSubmit @RequiresPermissions("ma:keeper:export") - @SysLog(title = "库管员配置", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出库管员配置") + @SysLog(title = "库管员配置", businessType = OperaType.EXPORT, module = "仓储管理->导出库管员配置") @PostMapping("/export") - public void export(HttpServletResponse response, TypeKeeper typeKeeper) - { + public void export(HttpServletResponse response, TypeKeeper typeKeeper) { List list = typeKeeperService.selectTypeKeeperList(typeKeeper); ExcelUtil util = new ExcelUtil(TypeKeeper.class); util.exportExcel(response, list, "库管员配置数据"); @@ -72,8 +68,7 @@ public class TypeKeeperController extends BaseController @ApiOperation(value = "获取库管员配置详细信息") @RequiresPermissions("ma:keeper:query") @GetMapping(value = "/{ID}") - public AjaxResult getInfo(@PathVariable("ID") Long ID) - { + public AjaxResult getInfo(@PathVariable("ID") Long ID) { return success(typeKeeperService.selectTypeKeeperByID(ID)); } @@ -83,10 +78,9 @@ public class TypeKeeperController extends BaseController @ApiOperation(value = "新增库管员配置") @PreventRepeatSubmit @RequiresPermissions("ma:keeper:add") - @SysLog(title = "库管员配置", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增库管员配置") + @SysLog(title = "库管员配置", businessType = OperaType.INSERT, module = "仓储管理->新增库管员配置") @PostMapping - public AjaxResult add(@RequestBody TypeKeeper typeKeeper) - { + public AjaxResult add(@RequestBody TypeKeeper typeKeeper) { return toAjax(typeKeeperService.insertTypeKeeper(typeKeeper)); } @@ -96,10 +90,9 @@ public class TypeKeeperController extends BaseController @ApiOperation(value = "修改库管员配置") @PreventRepeatSubmit @RequiresPermissions("ma:keeper:edit") - @SysLog(title = "库管员配置", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改库管员配置") + @SysLog(title = "库管员配置", businessType = OperaType.UPDATE, module = "仓储管理->修改库管员配置") @PutMapping - public AjaxResult edit(@RequestBody TypeKeeper typeKeeper) - { + public AjaxResult edit(@RequestBody TypeKeeper typeKeeper) { return toAjax(typeKeeperService.updateTypeKeeper(typeKeeper)); } @@ -109,7 +102,7 @@ public class TypeKeeperController extends BaseController @ApiOperation(value = "删除库管员配置") @PreventRepeatSubmit @RequiresPermissions("ma:keeper:remove") - @SysLog(title = "库管员配置", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除库管员配置") + @SysLog(title = "库管员配置", businessType = OperaType.DELETE, module = "仓储管理->删除库管员配置") @DeleteMapping("/{IDs}") public AjaxResult remove(@PathVariable Long[] IDs) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java index 3bf63608..660b4187 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java @@ -3,22 +3,20 @@ package com.bonus.material.ma.domain; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; /** * 库管员配置对象 ma_type_keeper - * - * @author xsheng - * @date 2024-09-27 */ - +@EqualsAndHashCode(callSuper = false) @Data @ToString -public class TypeKeeper extends BaseEntity -{ - private static final long serialVersionUID = 1L; +public class TypeKeeper extends BaseEntity { + + private static final long serialVersionUID = -5333521595576336827L; /** 主键ID */ private Long ID; @@ -27,10 +25,17 @@ public class TypeKeeper extends BaseEntity private Long typeId; /** 用户 */ - @Excel(name = "用户") - @ApiModelProperty(value = "用户") + @Excel(name = "用户ID") + @ApiModelProperty(value = "用户ID") private Long userId; + /** + * 用户名称 + */ + @Excel(name = "用户名称") + @ApiModelProperty(value = "用户名称") + private String userName; + /** 数据所属组织 */ @Excel(name = "数据所属组织") @ApiModelProperty(value = "数据所属组织") diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartRepairMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartRepairMapper.java index 830682a4..f5db8b41 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartRepairMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartRepairMapper.java @@ -5,12 +5,11 @@ import com.bonus.material.ma.domain.PartRepair; /** * 维修班配件配置Mapper接口 - * + * * @author xsheng * @date 2024-09-27 */ -public interface PartRepairMapper -{ +public interface PartRepairMapper { /** * 查询维修班配件配置 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java index 1273e086..4dc372fd 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java @@ -2,22 +2,20 @@ package com.bonus.material.ma.mapper; import java.util.List; import com.bonus.material.ma.domain.TypeKeeper; +import org.apache.ibatis.annotations.Mapper; /** * 库管员配置Mapper接口 - * - * @author xsheng - * @date 2024-09-27 */ -public interface TypeKeeperMapper -{ +@Mapper +public interface TypeKeeperMapper { /** * 查询库管员配置 * * @param ID 库管员配置主键 * @return 库管员配置 */ - public TypeKeeper selectTypeKeeperByID(Long ID); + TypeKeeper selectTypeKeeperByID(Long ID); /** * 查询库管员配置列表 @@ -25,7 +23,7 @@ public interface TypeKeeperMapper * @param typeKeeper 库管员配置 * @return 库管员配置集合 */ - public List selectTypeKeeperList(TypeKeeper typeKeeper); + List selectTypeKeeperList(TypeKeeper typeKeeper); /** * 新增库管员配置 @@ -33,7 +31,7 @@ public interface TypeKeeperMapper * @param typeKeeper 库管员配置 * @return 结果 */ - public int insertTypeKeeper(TypeKeeper typeKeeper); + int insertTypeKeeper(TypeKeeper typeKeeper); /** * 修改库管员配置 @@ -41,7 +39,7 @@ public interface TypeKeeperMapper * @param typeKeeper 库管员配置 * @return 结果 */ - public int updateTypeKeeper(TypeKeeper typeKeeper); + int updateTypeKeeper(TypeKeeper typeKeeper); /** * 删除库管员配置 @@ -49,7 +47,7 @@ public interface TypeKeeperMapper * @param ID 库管员配置主键 * @return 结果 */ - public int deleteTypeKeeperByID(Long ID); + int deleteTypeKeeperByID(Long ID); /** * 批量删除库管员配置 @@ -57,5 +55,5 @@ public interface TypeKeeperMapper * @param IDs 需要删除的数据主键集合 * @return 结果 */ - public int deleteTypeKeeperByIDs(Long[] IDs); + int deleteTypeKeeperByIDs(Long[] IDs); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java index 39a73c7a..701e600f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java @@ -5,19 +5,15 @@ import com.bonus.material.ma.domain.TypeKeeper; /** * 库管员配置Service接口 - * - * @author xsheng - * @date 2024-09-27 */ -public interface ITypeKeeperService -{ +public interface ITypeKeeperService { /** * 查询库管员配置 * * @param ID 库管员配置主键 * @return 库管员配置 */ - public TypeKeeper selectTypeKeeperByID(Long ID); + TypeKeeper selectTypeKeeperByID(Long ID); /** * 查询库管员配置列表 @@ -25,7 +21,7 @@ public interface ITypeKeeperService * @param typeKeeper 库管员配置 * @return 库管员配置集合 */ - public List selectTypeKeeperList(TypeKeeper typeKeeper); + List selectTypeKeeperList(TypeKeeper typeKeeper); /** * 新增库管员配置 @@ -33,7 +29,7 @@ public interface ITypeKeeperService * @param typeKeeper 库管员配置 * @return 结果 */ - public int insertTypeKeeper(TypeKeeper typeKeeper); + int insertTypeKeeper(TypeKeeper typeKeeper); /** * 修改库管员配置 @@ -41,7 +37,7 @@ public interface ITypeKeeperService * @param typeKeeper 库管员配置 * @return 结果 */ - public int updateTypeKeeper(TypeKeeper typeKeeper); + int updateTypeKeeper(TypeKeeper typeKeeper); /** * 批量删除库管员配置 @@ -49,7 +45,7 @@ public interface ITypeKeeperService * @param IDs 需要删除的库管员配置主键集合 * @return 结果 */ - public int deleteTypeKeeperByIDs(Long[] IDs); + int deleteTypeKeeperByIDs(Long[] IDs); /** * 删除库管员配置信息 @@ -57,5 +53,5 @@ public interface ITypeKeeperService * @param ID 库管员配置主键 * @return 结果 */ - public int deleteTypeKeeperByID(Long ID); + int deleteTypeKeeperByID(Long ID); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java index 11e4155b..0da9dd02 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java @@ -15,8 +15,8 @@ import com.bonus.material.ma.service.ITypeKeeperService; * @date 2024-09-27 */ @Service -public class TypeKeeperServiceImpl implements ITypeKeeperService -{ +public class TypeKeeperServiceImpl implements ITypeKeeperService { + @Autowired private TypeKeeperMapper typeKeeperMapper; @@ -27,8 +27,7 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService * @return 库管员配置 */ @Override - public TypeKeeper selectTypeKeeperByID(Long ID) - { + public TypeKeeper selectTypeKeeperByID(Long ID) { return typeKeeperMapper.selectTypeKeeperByID(ID); } @@ -39,8 +38,7 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService * @return 库管员配置 */ @Override - public List selectTypeKeeperList(TypeKeeper typeKeeper) - { + public List selectTypeKeeperList(TypeKeeper typeKeeper) { return typeKeeperMapper.selectTypeKeeperList(typeKeeper); } @@ -51,8 +49,7 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService * @return 结果 */ @Override - public int insertTypeKeeper(TypeKeeper typeKeeper) - { + public int insertTypeKeeper(TypeKeeper typeKeeper) { typeKeeper.setCreateTime(DateUtils.getNowDate()); return typeKeeperMapper.insertTypeKeeper(typeKeeper); } @@ -64,8 +61,7 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService * @return 结果 */ @Override - public int updateTypeKeeper(TypeKeeper typeKeeper) - { + public int updateTypeKeeper(TypeKeeper typeKeeper) { typeKeeper.setUpdateTime(DateUtils.getNowDate()); return typeKeeperMapper.updateTypeKeeper(typeKeeper); } @@ -77,8 +73,7 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService * @return 结果 */ @Override - public int deleteTypeKeeperByIDs(Long[] IDs) - { + public int deleteTypeKeeperByIDs(Long[] IDs) { return typeKeeperMapper.deleteTypeKeeperByIDs(IDs); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 078f9299..0803cd37 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -6,6 +6,7 @@ import java.util.Objects; import java.util.stream.Collectors; import com.bonus.common.biz.domain.TreeSelect; +import com.bonus.common.biz.enums.DataCodeEnum; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; import com.bonus.material.ma.vo.MaTypeListVo; @@ -49,9 +50,15 @@ public class TypeServiceImpl implements ITypeService { */ @Override public List selectTypeList(Type type) { - // 如果是顶级节点,则查询所有子节点 - if (type != null && "0".equals(type.getLevel())) { - type.setLevel(null); + if (type != null ) { + if (type.getDelFlag() == null || type.getDelFlag().isEmpty()) { + // 如果没赋值,则默认查询正常数据状态 + type.setDelFlag(String.valueOf(DataCodeEnum.NORMAL.getCode())); + } + // 如果是顶级节点,则查询所有子节点 + if ("0".equals(type.getLevel())) { + type.setLevel(null); + } } return typeMapper.selectTypeList(type); } @@ -130,6 +137,10 @@ public class TypeServiceImpl implements ITypeService { .collect(Collectors.toList()); } + /** + * 通过构造函数将 Type对象 转换为 TreeSelect -- 并递归处理子节点 + * @param type 要进行转换的object对象 + */ private TreeSelect convertToTreeSelect(Type type) { List children = type.getChildren().stream() .filter(Objects::nonNull) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java index b2de6065..573f8ba4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java @@ -33,8 +33,8 @@ import com.bonus.common.core.web.page.TableDataInfo; @Api(tags = "仓库管理接口") @RestController @RequestMapping("/wh_house_info") -public class WhHouseInfoController extends BaseController -{ +public class WhHouseInfoController extends BaseController { + @Autowired private IWhHouseInfoService whHouseInfoService; @@ -44,13 +44,23 @@ public class WhHouseInfoController extends BaseController @ApiOperation(value = "查询仓库管理列表") @RequiresPermissions("warehouse:info:list") @GetMapping("/list") - public TableDataInfo list(WhHouseInfo whHouseInfo) - { + public TableDataInfo list(WhHouseInfo whHouseInfo) { startPage(); List list = whHouseInfoService.selectWhHouseInfoList(whHouseInfo); return getDataTable(list); } + /** + * 查询仓库列表 -- 不分页 + */ + @ApiOperation(value = "查询仓库列表--不分页") + @RequiresPermissions("warehouse:info:list") + @GetMapping("/listNoPage") + public AjaxResult listNoPage(WhHouseInfo whHouseInfo) { + List list = whHouseInfoService.selectWhHouseInfoList(whHouseInfo); + return success(list); + } + /** * 导出仓库管理列表 */ @@ -59,8 +69,7 @@ public class WhHouseInfoController extends BaseController @RequiresPermissions("warehouse:info:export") @SysLog(title = "仓库管理", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出仓库管理") @PostMapping("/export") - public void export(HttpServletResponse response, WhHouseInfo whHouseInfo) - { + public void export(HttpServletResponse response, WhHouseInfo whHouseInfo) { List list = whHouseInfoService.selectWhHouseInfoList(whHouseInfo); ExcelUtil util = new ExcelUtil(WhHouseInfo.class); util.exportExcel(response, list, "仓库管理数据"); @@ -72,8 +81,7 @@ public class WhHouseInfoController extends BaseController @ApiOperation(value = "获取仓库管理详细信息") @RequiresPermissions("warehouse:info:query") @GetMapping(value = "/{houseId}") - public AjaxResult getInfo(@PathVariable("houseId") Long houseId) - { + public AjaxResult getInfo(@PathVariable("houseId") Long houseId) { return success(whHouseInfoService.selectWhHouseInfoByHouseId(houseId)); } @@ -85,8 +93,7 @@ public class WhHouseInfoController extends BaseController @RequiresPermissions("warehouse:info:add") @SysLog(title = "仓库管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增仓库管理") @PostMapping - public AjaxResult add(@RequestBody WhHouseInfo whHouseInfo) - { + public AjaxResult add(@RequestBody WhHouseInfo whHouseInfo) { return toAjax(whHouseInfoService.insertWhHouseInfo(whHouseInfo)); } @@ -98,8 +105,7 @@ public class WhHouseInfoController extends BaseController @RequiresPermissions("warehouse:info:edit") @SysLog(title = "仓库管理", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改仓库管理") @PutMapping - public AjaxResult edit(@RequestBody WhHouseInfo whHouseInfo) - { + public AjaxResult edit(@RequestBody WhHouseInfo whHouseInfo) { return toAjax(whHouseInfoService.updateWhHouseInfo(whHouseInfo)); } @@ -109,10 +115,9 @@ public class WhHouseInfoController extends BaseController @ApiOperation(value = "删除仓库管理") @PreventRepeatSubmit @RequiresPermissions("warehouse:info:remove") - @SysLog(title = "仓库管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除仓库管理") + @SysLog(title = "仓库管理", businessType = OperaType.DELETE, module = "仓储管理->删除仓库管理") @DeleteMapping("/{houseIds}") - public AjaxResult remove(@PathVariable Long[] houseIds) - { + public AjaxResult remove(@PathVariable Long[] houseIds) { return toAjax(whHouseInfoService.deleteWhHouseInfoByHouseIds(houseIds)); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseInfo.java index a80385f0..9e828752 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseInfo.java @@ -3,22 +3,20 @@ package com.bonus.material.warehouse.domain; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; /** * 仓库管理对象 wh_house_info - * - * @author xsheng - * @date 2024-09-27 + * @author bonus */ - - +@EqualsAndHashCode(callSuper = false) @Data @ToString -public class WhHouseInfo extends BaseEntity -{ - private static final long serialVersionUID = 1L; +public class WhHouseInfo extends BaseEntity { + + private static final long serialVersionUID = -6993602646196064834L; /** 仓库ID */ private Long houseId; @@ -28,6 +26,16 @@ public class WhHouseInfo extends BaseEntity @ApiModelProperty(value = "工程项目名称") private String houseName; + /** 实物库名称 */ + @Excel(name = "实物库名称") + @ApiModelProperty(value = "实物库名称") + private String physicalName; + + /** 仓库地理位置 */ + @Excel(name = "仓库地理位置") + @ApiModelProperty(value = "仓库地址位置") + private String geoLocation; + /** 上级ID */ @Excel(name = "上级ID") @ApiModelProperty(value = "上级ID") @@ -43,11 +51,12 @@ public class WhHouseInfo extends BaseEntity private Long deptId; /** 删除标志(0代表存在 2代表删除) */ + @ApiModelProperty(value = "删除标志(0存在 2代表已删除)") private String delFlag; /** 数据所属组织 */ - @Excel(name = "数据所属组织") - @ApiModelProperty(value = "数据所属组织") + @Excel(name = "所属组织") + @ApiModelProperty(value = "所属组织") private String companyId; /** 排序 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseInfoMapper.java index a07ddada..82976b74 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseInfoMapper.java @@ -25,7 +25,7 @@ public interface WhHouseInfoMapper * @param whHouseInfo 仓库管理 * @return 仓库管理集合 */ - public List selectWhHouseInfoList(WhHouseInfo whHouseInfo); + List selectWhHouseInfoList(WhHouseInfo whHouseInfo); /** * 新增仓库管理 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseInfoService.java index 56f3c7b7..d0736cd2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseInfoService.java @@ -9,15 +9,14 @@ import com.bonus.material.warehouse.domain.WhHouseInfo; * @author xsheng * @date 2024-09-27 */ -public interface IWhHouseInfoService -{ +public interface IWhHouseInfoService { /** * 查询仓库管理 * * @param houseId 仓库管理主键 * @return 仓库管理 */ - public WhHouseInfo selectWhHouseInfoByHouseId(Long houseId); + WhHouseInfo selectWhHouseInfoByHouseId(Long houseId); /** * 查询仓库管理列表 @@ -25,7 +24,7 @@ public interface IWhHouseInfoService * @param whHouseInfo 仓库管理 * @return 仓库管理集合 */ - public List selectWhHouseInfoList(WhHouseInfo whHouseInfo); + List selectWhHouseInfoList(WhHouseInfo whHouseInfo); /** * 新增仓库管理 @@ -33,7 +32,7 @@ public interface IWhHouseInfoService * @param whHouseInfo 仓库管理 * @return 结果 */ - public int insertWhHouseInfo(WhHouseInfo whHouseInfo); + int insertWhHouseInfo(WhHouseInfo whHouseInfo); /** * 修改仓库管理 @@ -41,7 +40,7 @@ public interface IWhHouseInfoService * @param whHouseInfo 仓库管理 * @return 结果 */ - public int updateWhHouseInfo(WhHouseInfo whHouseInfo); + int updateWhHouseInfo(WhHouseInfo whHouseInfo); /** * 批量删除仓库管理 @@ -49,7 +48,7 @@ public interface IWhHouseInfoService * @param houseIds 需要删除的仓库管理主键集合 * @return 结果 */ - public int deleteWhHouseInfoByHouseIds(Long[] houseIds); + int deleteWhHouseInfoByHouseIds(Long[] houseIds); /** * 删除仓库管理信息 @@ -57,5 +56,5 @@ public interface IWhHouseInfoService * @param houseId 仓库管理主键 * @return 结果 */ - public int deleteWhHouseInfoByHouseId(Long houseId); + int deleteWhHouseInfoByHouseId(Long houseId); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseInfoServiceImpl.java index 6680527b..09eebf28 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseInfoServiceImpl.java @@ -39,8 +39,7 @@ public class WhHouseInfoServiceImpl implements IWhHouseInfoService * @return 仓库管理 */ @Override - public List selectWhHouseInfoList(WhHouseInfo whHouseInfo) - { + public List selectWhHouseInfoList(WhHouseInfo whHouseInfo) { return whHouseInfoMapper.selectWhHouseInfoList(whHouseInfo); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml index 7260d12f..6394a01b 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml @@ -52,8 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" type_id = #{typeId}, user_id = #{userId}, - create_time = #{createTime}, - update_time = #{updateTime}, + update_time = #{updateTime}, company_id = #{companyId}, where ID = #{ID} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 2576399c..342aee02 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and is_ancuo = #{isAncuo} and fac_model = #{facModel} and intelligent_code = #{intelligentCode} - and del_flag = '0' + and del_flag = #{delFlag} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/warehouse/WhHouseInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/warehouse/WhHouseInfoMapper.xml index 144fe4b6..5c41eadc 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/warehouse/WhHouseInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/warehouse/WhHouseInfoMapper.xml @@ -6,6 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -22,13 +24,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select house_id, house_name, parent_id, status, dept_id, del_flag, create_by, create_time, update_by, update_time, remark, company_id, sort, concat, phone from wh_house_info + select house_id, house_name, physical_name, geo_location, parent_id, status, dept_id, del_flag, create_by, create_time, update_by, update_time, remark, company_id, sort, concat, phone from wh_house_info + + insert into ma_type @@ -187,7 +247,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where del_flag = 0 and level != #{level} - SELECT a.*, -- 当前层级的所有字段 a.type_name AS parentFourLevelName, -- 当前层级名称 @@ -227,4 +287,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.del_flag = '0' + + \ No newline at end of file From 0b694fe72ad9902dd18e4cb620942d070bb1029a Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Tue, 15 Oct 2024 15:28:02 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E6=A0=91=E5=BD=A2=E6=96=B0=E5=A2=9E0?= =?UTF-8?q?=E7=BA=A7=E4=BB=93=E5=BA=93=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/common/biz/domain/TreeSelect.java | 7 +++ .../ma/controller/MachineController.java | 4 +- .../ma/controller/TypeController.java | 52 ++++++++++++++++++- .../bonus/material/ma/mapper/TypeMapper.java | 10 ++++ .../material/ma/service/ITypeService.java | 4 ++ .../ma/service/impl/TypeServiceImpl.java | 26 ++++++++-- .../controller/WhHouseInfoController.java | 2 +- .../controller/WhHouseSetController.java | 4 +- .../material/warehouse/domain/WhHouseSet.java | 16 +++++- .../warehouse/mapper/WhHouseSetMapper.java | 9 +++- .../warehouse/service/IWhHouseSetService.java | 2 + .../service/impl/WhHouseSetServiceImpl.java | 8 +++ .../mapper/material/ma/TypeMapper.xml | 1 - .../material/warehouse/WhHouseSetMapper.xml | 12 +++++ 14 files changed, 144 insertions(+), 13 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java index fc39260b..30a74855 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java @@ -46,4 +46,11 @@ public class TreeSelect implements Serializable { this.children = children; } + public TreeSelect(Long id, String label, Integer level, Long parentId) { + this.id = id; + this.label = label; + this.level = level; + this.parentId = parentId; + } + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java index 68d63bc9..652a4acf 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java @@ -33,8 +33,8 @@ import com.bonus.common.core.web.page.TableDataInfo; @Api(tags = "机具设备管理接口") @RestController @RequestMapping("/ma_machine") -public class MachineController extends BaseController -{ +public class MachineController extends BaseController { + @Autowired private IMachineService machineService; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index ab0e2f54..13530590 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -1,12 +1,18 @@ package com.bonus.material.ma.controller; +import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.convert.Convert; +import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.warehouse.domain.WhHouseSet; +import com.bonus.material.warehouse.service.IWhHouseSetService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -31,6 +37,9 @@ public class TypeController extends BaseController { @Resource private ITypeService typeService; + @Resource + private IWhHouseSetService houseSetService; + /** * 查询物资类型管理列表 */ @@ -43,6 +52,26 @@ public class TypeController extends BaseController { return getDataTable(list); } + /** + * 根据左列表类型id查询右表格 + * + * @param typeId + * @return + */ + @ApiOperation(value = "根据左列表类型id查询右表格") + @GetMapping("/getListByMaType") + public AjaxResult getListByMaType(Long typeId, @RequestParam(required = false) String typeName, Integer level) { + List parentIds = typeService.selectParentId(typeId, level); + List listByMaType = new ArrayList<>(); + for (Integer parentId : parentIds) { + listByMaType.addAll(typeService.getListByParentId(parentId.longValue(), typeName)); + } +// Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); +// Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); +// return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, listByMaType)); + return null; + } + /** * 物资类型下拉树 */ @@ -50,8 +79,29 @@ public class TypeController extends BaseController { @RequiresPermissions("ma:type:list") @GetMapping("/getMaTypeTreeSelect") public AjaxResult getMaTypeTreeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) { + // 1.顶级节点及子节点数据全部查询完毕 List maTypeList = typeService.getMaTypeTree(typeName, parentId); - return AjaxResult.success(maTypeList); + // 2.查询所有的仓库配置 + List whHouseSets = houseSetService.selectListByMaType(null); + // 2.1 定义最终接口返回集合 + List treeSelectResultList = new ArrayList<>(); + // 3.遍历所有配置关联 + for (WhHouseSet whHouseSet : whHouseSets) { + Long typeId = whHouseSet.getTypeId(); + if (typeId == null) {continue;} + // 构造函数定义0级Tree对象 + TreeSelect thisTree = new TreeSelect(whHouseSet.getId(),whHouseSet.getHouseName(),0,null); + // 定义1级列表,并循环push相应的1级节点 + List oneLevelTreeList = new ArrayList<>(); + for (TreeSelect treeSelect : maTypeList) { + if (treeSelect.getId().equals(typeId)) { + oneLevelTreeList.add(treeSelect); + } + } + thisTree.setChildren(oneLevelTreeList); + treeSelectResultList.add(thisTree); + } + return AjaxResult.success(treeSelectResultList); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index 835c6cb1..c09519bd 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -20,6 +20,16 @@ public interface TypeMapper { */ Type selectTypeByTypeId(Long typeId); + /** + * 根据level层级和typeID 查询父级ID + * @param typeId 物资类型主键 + * @param level 类型层级 + */ + List selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level); + + + List getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName); + /** * 物资类型树形结构 * @param level 排除层级 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index fd03bea3..85cb89b2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -19,6 +19,10 @@ public interface ITypeService { */ Type selectTypeByTypeId(Long typeId); + List selectParentId(Long typeId, Integer level); + + List getListByParentId(Long typeId, String typeName); + /** * 查询物资类型列表 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 0803cd37..f401dc0a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -42,6 +42,22 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.selectTypeByTypeId(typeId); } + @Override + public List selectParentId(Long typeId, Integer level) { + return typeMapper.selectParentId(typeId, level); + } + + /** + * 根据组织树parent_id查询结果 + * + * @param typeId 父级id + * @param typeName 名称筛选 + */ + @Override + public List getListByParentId(Long typeId, String typeName) { + return typeMapper.getListByParentId(typeId, typeName); + } + /** * 查询物资类型管理列表 * @@ -128,13 +144,17 @@ public class TypeServiceImpl implements ITypeService { @Override public List getMaTypeTree(String typeName, String parentId) { List maTypes = typeMapper.selectMaTypeTree(TYPE_MIN_LEVEL); - List treeSelectList = buildMaTypeTree(maTypes); + List builtMaTypeList = buildMaTypeTree(maTypes); - // 如果没有查询到那么返回空 - return treeSelectList.stream() + List treeSelectList = builtMaTypeList.stream() .filter(Objects::nonNull) .map(this::convertToTreeSelect) .collect(Collectors.toList()); + + // 查询顶级节点的仓库配置信息 + + // 如果没有查询到那么返回空 + return treeSelectList; } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java index 573f8ba4..a92c19b8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java @@ -67,7 +67,7 @@ public class WhHouseInfoController extends BaseController { @ApiOperation(value = "导出仓库管理列表") @PreventRepeatSubmit @RequiresPermissions("warehouse:info:export") - @SysLog(title = "仓库管理", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出仓库管理") + @SysLog(title = "仓库管理", businessType = OperaType.EXPORT, module = "仓储管理->导出仓库管理") @PostMapping("/export") public void export(HttpServletResponse response, WhHouseInfo whHouseInfo) { List list = whHouseInfoService.selectWhHouseInfoList(whHouseInfo); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java index 36e2f9ee..58f368e9 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java @@ -33,8 +33,8 @@ import com.bonus.common.core.web.page.TableDataInfo; @Api(tags = "仓库货架配置接口") @RestController @RequestMapping("/wh_house_set") -public class WhHouseSetController extends BaseController -{ +public class WhHouseSetController extends BaseController { + @Autowired private IWhHouseSetService whHouseSetService; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java index 848eae97..8cef9dd3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java @@ -1,11 +1,15 @@ package com.bonus.material.warehouse.domain; +import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; +import java.util.ArrayList; +import java.util.List; + /** * 仓库货架配置对象 wh_house_set * @@ -16,8 +20,8 @@ import com.bonus.common.core.web.domain.BaseEntity; @Data @ToString -public class WhHouseSet extends BaseEntity -{ +public class WhHouseSet extends BaseEntity { + private static final long serialVersionUID = 1L; /** 主键id */ @@ -28,6 +32,10 @@ public class WhHouseSet extends BaseEntity @ApiModelProperty(value = "仓库ID") private Long houseId; + @Excel(name = "仓库名称") + @ApiModelProperty(value = "仓库名称") + private String houseName; + /** 机具类型ID */ @Excel(name = "机具类型ID") @ApiModelProperty(value = "机具类型ID") @@ -65,5 +73,9 @@ public class WhHouseSet extends BaseEntity @ApiModelProperty(value = "货架编号") private String shelfNum; + /** + * 仓库下物资树 + */ + private List treeSelectList = new ArrayList<>(); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java index 6d29a8cd..128dae9f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java @@ -25,7 +25,14 @@ public interface WhHouseSetMapper * @param whHouseSet 仓库货架配置 * @return 仓库货架配置集合 */ - public List selectWhHouseSetList(WhHouseSet whHouseSet); + List selectWhHouseSetList(WhHouseSet whHouseSet); + + + /** + * 根据物资类型id查询机具列表 + * @param typeId 物资类型id + */ + List selectListByMaType(Long typeId); /** * 新增仓库货架配置 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java index 099d74f6..0d384784 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java @@ -27,6 +27,8 @@ public interface IWhHouseSetService */ public List selectWhHouseSetList(WhHouseSet whHouseSet); + List selectListByMaType(Long typeId); + /** * 新增仓库货架配置 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java index 9e77c606..dff1857a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java @@ -44,6 +44,14 @@ public class WhHouseSetServiceImpl implements IWhHouseSetService return whHouseSetMapper.selectWhHouseSetList(whHouseSet); } + + @Override + public List selectListByMaType(Long typeId) { + return whHouseSetMapper.selectListByMaType(typeId); + } + ; + + /** * 新增仓库货架配置 * diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 69e6fd13..5bc1997e 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -250,7 +250,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + SELECT + mhs.house_id, mhs.type_id, mhs.ma_id, mhs.num, mhs.status, mhs.dept_id, mhs.del_flag, + mhs.create_by, mhs.create_time, mhs.update_by,mhs.update_time,mhs.remark,mhs.company_id,mhi.house_name + from wh_house_set mhs + left join ma_type mt on mt.type_id = mhs.type_id + left join ma_type mt1 on mt.parent_id = mt1.type_id + left join ma_type mt2 on mt1.parent_id = mt2.type_id + left join wh_house_info mhi on mhs.house_id = mhi.house_id + \ No newline at end of file From 0d3f737406aff50e93d2bf1b33ad49793118e0bf Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Tue, 15 Oct 2024 16:12:37 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E6=96=B0=E5=A2=9E=E7=89=A9=E8=B5=84?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E6=9F=A5=E8=AF=A2=E6=A0=91=E7=8A=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeController.java | 28 ++++++++++++++----- .../bonus/material/ma/mapper/TypeMapper.java | 10 ++++++- .../material/ma/service/ITypeService.java | 3 ++ .../ma/service/impl/TypeServiceImpl.java | 8 +++++- .../bonus/material/ma/vo/MaTypeSelectVo.java | 23 +++++++++++++++ .../mapper/material/ma/TypeMapper.xml | 15 +++++++++- 6 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index 13530590..9f46131d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -4,13 +4,14 @@ import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; -import cn.hutool.core.convert.Convert; -import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; import com.bonus.material.warehouse.domain.WhHouseSet; import com.bonus.material.warehouse.service.IWhHouseSetService; import io.swagger.annotations.Api; @@ -53,10 +54,20 @@ public class TypeController extends BaseController { } /** - * 根据左列表类型id查询右表格 - * - * @param typeId - * @return + * 根据物资仓库ID查询施工类型 + */ + @ApiOperation(value = "根据物资仓库ID查询施工类型") + @RequiresPermissions("ma:type:list") + @GetMapping("/selectMaTypeListByHouseId") + public AjaxResult selectMaTypeListByHouseId(@NotNull(message = "物资仓库ID不能为空") Long houseId) { + List list = typeService.selectMaTypeListByHouseId(houseId); + return success(list); + } + + /** + * 根据左列表类型id查询右表格 --- 暂未启用,代码有问题!! + * TODO: 待完善 + * @param typeId 左列表类型id */ @ApiOperation(value = "根据左列表类型id查询右表格") @GetMapping("/getListByMaType") @@ -73,6 +84,7 @@ public class TypeController extends BaseController { } /** + * TODO : 后续优化代码逻辑 * 物资类型下拉树 */ @ApiOperation(value = "物资类型下拉树") @@ -98,7 +110,9 @@ public class TypeController extends BaseController { oneLevelTreeList.add(treeSelect); } } - thisTree.setChildren(oneLevelTreeList); + // 把处理后对应上的1级列表当作child存入0级Tree对象中 + thisTree.setChildren(!oneLevelTreeList.isEmpty() ? oneLevelTreeList : null); + // 最后把0级Tree对象存入Result返回集合中,返回给前端 treeSelectResultList.add(thisTree); } return AjaxResult.success(treeSelectResultList); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index c09519bd..9496f448 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -3,6 +3,7 @@ package com.bonus.material.ma.mapper; import java.util.List; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -27,8 +28,15 @@ public interface TypeMapper { */ List selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level); + /** + * 根据物资仓库的ID查询物资类型列表 + * @param houseId 物资仓库ID + */ + List selectMaTypeListByHouseId(Long houseId); - List getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName); + List getListByTypeName(@Param("typeId") Long typeId, @Param("typeName") String typeName); + + List getMaTypeSelectVoListByParentId(@Param("typeId") Long typeId); /** * 物资类型树形结构 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 85cb89b2..807139ec 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -5,6 +5,7 @@ import java.util.List; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; /** * 物资类型Service接口 @@ -21,6 +22,8 @@ public interface ITypeService { List selectParentId(Long typeId, Integer level); + List selectMaTypeListByHouseId(Long houseId); + List getListByParentId(Long typeId, String typeName); /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index f401dc0a..77f1ad92 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -10,6 +10,7 @@ import com.bonus.common.biz.enums.DataCodeEnum; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; import org.springframework.stereotype.Service; import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.ma.domain.Type; @@ -47,6 +48,11 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.selectParentId(typeId, level); } + @Override + public List selectMaTypeListByHouseId(Long houseId) { + return typeMapper.selectMaTypeListByHouseId(houseId); + } + /** * 根据组织树parent_id查询结果 * @@ -55,7 +61,7 @@ public class TypeServiceImpl implements ITypeService { */ @Override public List getListByParentId(Long typeId, String typeName) { - return typeMapper.getListByParentId(typeId, typeName); + return typeMapper.getListByTypeName(typeId, typeName); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java new file mode 100644 index 00000000..2e247f91 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java @@ -0,0 +1,23 @@ +package com.bonus.material.ma.vo; + +import lombok.Data; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.ma.vo + * @CreateTime: 2024-10-15 15:39 + * @Description: 物资类型下拉框 + */ +@Data +public class MaTypeSelectVo { + + private Long typeId; + + private String typeName; + + private String parentId; + + private Integer level; + +} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 5bc1997e..8fdd780b 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -287,7 +287,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select DISTINCT m.type_id, m.type_name, m.parent_id, m.manage_type, m.lease_price,m.rent_price, m.eff_time, m.buy_price, m.level, m.rated_load, m.test_load, m.holding_time, m.warn_num, @@ -303,4 +303,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND type_name like concat('%',#{typeName},'%') + + \ No newline at end of file From 398c4502681523631793ba0b5d02a9b0ca572ee5 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Tue, 15 Oct 2024 16:23:06 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E6=96=B0=E5=A2=9E=E7=88=B6=E7=BA=A7?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=AD=90=E7=BA=A7tree=E6=A0=91=E5=BD=A2?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/material/ma/controller/TypeController.java | 11 +++++++++++ .../com/bonus/material/ma/mapper/TypeMapper.java | 6 +++++- .../com/bonus/material/ma/service/ITypeService.java | 6 ++++++ .../material/ma/service/impl/TypeServiceImpl.java | 5 +++++ .../main/resources/mapper/material/ma/TypeMapper.xml | 12 ++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index 9f46131d..7960388e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -64,6 +64,17 @@ public class TypeController extends BaseController { return success(list); } + /** + * 根据物资类型ID查询所属下拉列表 + */ + @ApiOperation(value = "根据物资类型ID查询所属下拉列表") + @RequiresPermissions("ma:type:list") + @GetMapping("/selectMaTypeListByTypeId") + public AjaxResult selectMaTypeListByTypeId(@NotNull(message = "物资类型ID不能为空") Long typeId) { + List list = typeService.getMaTypeSelectVoListByParentId(typeId); + return success(list); + } + /** * 根据左列表类型id查询右表格 --- 暂未启用,代码有问题!! * TODO: 待完善 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index 9496f448..30af360e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -36,7 +36,11 @@ public interface TypeMapper { List getListByTypeName(@Param("typeId") Long typeId, @Param("typeName") String typeName); - List getMaTypeSelectVoListByParentId(@Param("typeId") Long typeId); + /** + * 查询物资类型下拉树结构--根据上级ID + * @param parentId 父级ID + */ + List getMaTypeSelectVoListByParentId(@Param("parentId") Long parentId); /** * 物资类型树形结构 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 807139ec..6ea729cc 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -26,6 +26,12 @@ public interface ITypeService { List getListByParentId(Long typeId, String typeName); + /** + * 查询物资类型下拉树结构--根据上级ID + * @param parentId 父级id + */ + List getMaTypeSelectVoListByParentId(Long parentId); + /** * 查询物资类型列表 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 77f1ad92..875ee3a1 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -64,6 +64,11 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.getListByTypeName(typeId, typeName); } + @Override + public List getMaTypeSelectVoListByParentId(Long parentId) { + return typeMapper.getMaTypeSelectVoListByParentId(parentId); + } + /** * 查询物资类型管理列表 * diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 8fdd780b..ea79b697 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -316,4 +316,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where wh_house_set.house_id = #{mouseId} and wh_house_set.del_flag = 0 + + \ No newline at end of file From e85219e6f515b14d4ac706487eb1de098844e40a Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Tue, 15 Oct 2024 18:13:34 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E5=AF=B94=E7=BA=A7=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=BF=9B=E8=A1=8C=E6=95=B0=E6=8D=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeController.java | 4 +- .../ma/service/impl/TypeServiceImpl.java | 55 ++++++++++++++++++- .../mapper/material/ma/TypeMapper.xml | 41 +++++++------- 3 files changed, 77 insertions(+), 23 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index 7960388e..0a7bc6c5 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -65,9 +65,9 @@ public class TypeController extends BaseController { } /** - * 根据物资类型ID查询所属下拉列表 + * 根据物资类型ID查询子级下拉列表 --不进行递归穿透 */ - @ApiOperation(value = "根据物资类型ID查询所属下拉列表") + @ApiOperation(value = "根据物资类型ID-查询子级下拉列表") @RequiresPermissions("ma:type:list") @GetMapping("/selectMaTypeListByTypeId") public AjaxResult selectMaTypeListByTypeId(@NotNull(message = "物资类型ID不能为空") Long typeId) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 875ee3a1..2057fa68 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -99,10 +99,61 @@ public class TypeServiceImpl implements ITypeService { @Override public List selectTypeListAndParent(Type type) { // 如果是顶级节点,则查询所有子节点 - if (type != null && "0".equals(type.getLevel())) { + if (type != null && type.getLevel() != null && "0".equals(type.getLevel())) { type.setLevel(null); } - return typeMapper.selectTypeListAndParent(type); + + // 拿到数据要处理一下上级信息 + List maTypeListVos; + try { + maTypeListVos = typeMapper.selectTypeListAndParent(type); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + + // 检查Mapper集合 + if (maTypeListVos == null || maTypeListVos.isEmpty()) { + return new ArrayList<>(); + } + + + for (MaTypeListVo maTypeListVo : maTypeListVos) { + // ------------ 检查 ----------- + + // object对象是空的,忽略处理 + if (maTypeListVo == null) { + continue; + } + // 没有上级就不需要处理,或者level等级不清晰的也不进行处理 + if (maTypeListVo.getParentId() == null || maTypeListVo.getLevel() == null) { + continue; + } + // 1级节点已经是顶级,无上级,所以不需要处理 + if ("1".equals(maTypeListVo.getLevel())) { + continue; + } + // ------------ 检查结束 ----------- + + + // 进行数据处理 + switch (maTypeListVo.getLevel()) { + case "2": + // 二级节点父级是一级节点,所以要拿到父节点名称,并赋值至ONE_LEVEL_NAME字段 + maTypeListVo.setParentOneLevelName(maTypeListVo.getParentThreeLevelName() == null ? "" : maTypeListVo.getParentThreeLevelName()); + break; + case "3": + // 三级节点父级是二级节点和一级节点, 要把祖父类型名称放入一级字段,把父类型名称存入二级字段 + maTypeListVo.setParentOneLevelName(maTypeListVo.getParentTwoLevelName() == null ? "" : maTypeListVo.getParentTwoLevelName()); + maTypeListVo.setParentTwoLevelName(maTypeListVo.getParentThreeLevelName() == null ? "" : maTypeListVo.getParentThreeLevelName()); + break; + case "4": + // 四级节点父级是三级节点和二级节点和一级节点, 要把祖父类型名称放入一级字段,把父类型名称存入二级字段,子类型名称存入三级字段 + // 但因为4级节点内循环3次,已按顺序处理,所以此处无需处理 + break; + } + + } + return maTypeListVos; } /** diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index ea79b697..be58065a 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -251,6 +251,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT a.*, -- 当前层级的所有字段 b.type_name AS parentThreeLevelName, -- 父层级名称 + c.type_name AS parentTwoLevelName, -- 祖父层级名称 d.type_name AS parentOneLevelName -- 曾祖父层级名称 FROM @@ -288,17 +289,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select wh_house_set.type_id AS typeId, - mt.type_name AS typeName, - mt.parent_id AS parentId, - mt.level + mt.type_name AS typeName,mt.parent_id AS parentId,mt.level from wh_house_set - left join ma_type mt on wh_house_set.type_id = mt.type_id + left join + ma_type mt on wh_house_set.type_id = mt.type_id where wh_house_set.house_id = #{mouseId} and wh_house_set.del_flag = 0 @@ -59,8 +60,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" del_flag, create_by, create_time, - update_by, - update_time, remark, company_id, status, @@ -76,8 +75,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{delFlag}, #{createBy}, #{createTime}, - #{updateBy}, - #{updateTime}, #{remark}, #{companyId}, #{status}, @@ -94,9 +91,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" phone = #{phone}, business_scope = #{businessScope}, business_license = #{businessLicense}, - del_flag = #{delFlag}, - create_by = #{createBy}, - create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, @@ -107,11 +101,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from ma_supplier_info where supplier_id = #{supplierId} + update ma_supplier_info set del_flag = 2 where supplier_id = #{supplierId} - delete from ma_supplier_info where supplier_id in + update ma_supplier_info set del_flag = 2 where supplier_id in #{supplierId} From a88a02926b937bf87a1f63bdcf0f38660649d55f Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Wed, 16 Oct 2024 09:16:15 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E7=89=A9=E8=B5=84=E5=8E=82=E5=AE=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E6=B3=A8=E9=87=8A=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bonus/material/ma/domain/SupplierInfo.java | 2 +- .../material/ma/mapper/SupplierInfoMapper.java | 14 ++++++-------- .../ma/service/impl/SupplierInfoServiceImpl.java | 12 ++++-------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/SupplierInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/SupplierInfo.java index bc736808..71f67ca1 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/SupplierInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/SupplierInfo.java @@ -20,7 +20,7 @@ public class SupplierInfo extends BaseEntity { private static final long serialVersionUID = 1720446126255482527L; - /** 仓库ID */ + /** 厂家ID */ private Long supplierId; /** 名称 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/SupplierInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/SupplierInfoMapper.java index 5aca4ef7..63cdc5b1 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/SupplierInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/SupplierInfoMapper.java @@ -5,13 +5,11 @@ import com.bonus.material.ma.domain.SupplierInfo; /** * 物资厂家管理Mapper接口 - * - * @author xsheng - * @date 2024-09-27 + * @author syruan */ public interface SupplierInfoMapper { /** - * 查询物资厂家管理 + * 根据id查询物资厂家 * * @param supplierId 物资厂家管理主键 * @return 物资厂家管理 @@ -27,7 +25,7 @@ public interface SupplierInfoMapper { List selectSupplierInfoList(SupplierInfo supplierInfo); /** - * 新增物资厂家管理 + * 新增物资厂家 * * @param supplierInfo 物资厂家管理 * @return 结果 @@ -35,7 +33,7 @@ public interface SupplierInfoMapper { int insertSupplierInfo(SupplierInfo supplierInfo); /** - * 修改物资厂家管理 + * 修改物资厂家 * * @param supplierInfo 物资厂家管理 * @return 结果 @@ -43,7 +41,7 @@ public interface SupplierInfoMapper { int updateSupplierInfo(SupplierInfo supplierInfo); /** - * 删除物资厂家管理 + * 删除物资厂家 * * @param supplierId 物资厂家管理主键 * @return 结果 @@ -51,7 +49,7 @@ public interface SupplierInfoMapper { int deleteSupplierInfoBySupplierId(Long supplierId); /** - * 批量删除物资厂家管理 + * 批量删除物资厂家 * * @param supplierIds 需要删除的数据主键集合 * @return 结果 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/SupplierInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/SupplierInfoServiceImpl.java index ab18e9ec..ba057dfe 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/SupplierInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/SupplierInfoServiceImpl.java @@ -13,8 +13,7 @@ import javax.annotation.Resource; /** * 物资厂家管理Service业务层处理 * - * @author xsheng - * @date 2024-09-27 + * @author bonus */ @Service public class SupplierInfoServiceImpl implements ISupplierInfoService { @@ -28,8 +27,7 @@ public class SupplierInfoServiceImpl implements ISupplierInfoService { * @return 物资厂家管理 */ @Override - public SupplierInfo selectSupplierInfoBySupplierId(Long supplierId) - { + public SupplierInfo selectSupplierInfoBySupplierId(Long supplierId) { return supplierInfoMapper.selectSupplierInfoBySupplierId(supplierId); } @@ -40,8 +38,7 @@ public class SupplierInfoServiceImpl implements ISupplierInfoService { * @return 物资厂家管理 */ @Override - public List selectSupplierInfoList(SupplierInfo supplierInfo) - { + public List selectSupplierInfoList(SupplierInfo supplierInfo) { return supplierInfoMapper.selectSupplierInfoList(supplierInfo); } @@ -52,8 +49,7 @@ public class SupplierInfoServiceImpl implements ISupplierInfoService { * @return 结果 */ @Override - public int insertSupplierInfo(SupplierInfo supplierInfo) - { + public int insertSupplierInfo(SupplierInfo supplierInfo) { supplierInfo.setCreateTime(DateUtils.getNowDate()); return supplierInfoMapper.insertSupplierInfo(supplierInfo); }