From 7376ca74218fbfddc93d50830ea30c27caac6d49 Mon Sep 17 00:00:00 2001 From: mashuai Date: Wed, 16 Oct 2024 17:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E4=BB=B6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bonus/common/biz/domain/MaType.java | 107 ------------------ .../bonus/common/biz/domain/SysDeptTree.java | 89 --------------- .../controller/BmUnitPersonController.java | 38 ++++++- .../basic/mapper/BmUnitPersonMapper.java | 1 - .../ma/controller/PartTypeController.java | 16 +-- .../bonus/material/ma/domain/PartType.java | 5 +- .../material/ma/mapper/PartTypeMapper.java | 37 ++++-- .../material/ma/service/IPartTypeService.java | 20 +--- .../ma/service/impl/PartTypeServiceImpl.java | 75 ++++++++---- .../mapper/material/ma/PartTypeMapper.xml | 72 ++++++++---- 10 files changed, 177 insertions(+), 283 deletions(-) delete mode 100644 bonus-common-biz/src/main/java/com/bonus/common/biz/domain/MaType.java delete mode 100644 bonus-common-biz/src/main/java/com/bonus/common/biz/domain/SysDeptTree.java diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/MaType.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/MaType.java deleted file mode 100644 index 86612033..00000000 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/MaType.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.bonus.common.biz.domain; - -import com.bonus.common.core.web.domain.BaseEntity; -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class MaType extends BaseEntity implements Serializable { - private static final long serialVersionUID = 135108051525707131L; - - private Integer isExport; - /** - * id - */ - private String id; - /** - * 上级id - */ - private String parentId; - /** - * 名称 - */ - private String name; - - /** - * 父级名称 - */ - private String parentName; - - /** - * 编码 - */ - private String code; - - /** - * 层级 - */ - private String level; - /** - * 库存 - */ - private Integer storageNum; - /** - * 计量单位id - */ - private String unitId; - - /** - * 计量单位名称 - */ - private String unitName; - /** - * 采购单价 - */ - private Integer buyPrice; - /** - * 租赁单价 - */ - private Integer leasePrice; - /** - * 管理类型(0是编码 1数量) - */ - private String manageType; - /** - * 是否启用 - */ - private String isActive; - /** - * 额定载荷 - */ - private String rateLoad; - /** - * 试验载荷 - */ - private String testLoad; - /** - * 持荷时间 (分钟) - */ - private String holdTime; - /** - * 文件路径 - */ - private String fileUrl; - /** - * 数据所属 - */ - private String companyId; - - /** - * 是否试验(0 否 1是) - */ - private String isTest; - - /** 子节点 */ - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List children = new ArrayList<>(); - -} - diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/SysDeptTree.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/SysDeptTree.java deleted file mode 100644 index 2482c4e1..00000000 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/SysDeptTree.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.bonus.common.biz.domain; - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.Data; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * 部门表(SysDept)实体类 - * - * @author makejava - * @since 2024-08-15 13:44:56 - */ -@Data -public class SysDeptTree implements Serializable { - - private static final long serialVersionUID = 991828482042492876L; - - /** - * 二级树标识 1代表查询二级树 - */ - private Integer isTree; - - /** - * 更新时间 - */ - private Date updateTime; - /** - * 更新者 - */ - private String updateBy; - /** - * 创建时间 - */ - private Date createTime; - /** - * 创建者 - */ - private String createBy; - /** - * 删除标志(0代表存在 2代表删除) - */ - private String delFlag; - /** - * 部门状态(0正常 1停用) - */ - private String status; - /** - * 邮箱 - */ - private String email; - /** - * 联系电话 - */ - private String phone; - /** - * 负责人 - */ - private String leader; - /** - * 显示顺序 - */ - private Integer orderNum; - /** - * 部门名称 - */ - private String deptName; - /** - * 祖级列表 - */ - private String ancestors; - /** - * 父部门id - */ - private String parentId; - /** - * 部门id - */ - private String deptId; - - /** 子节点 */ - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List children = new ArrayList<>(); - -} - diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmUnitPersonController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmUnitPersonController.java index 774f3b97..1e02b47c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmUnitPersonController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmUnitPersonController.java @@ -1,8 +1,12 @@ package com.bonus.material.basic.controller; +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.system.api.RemoteUserService; +import com.bonus.system.api.domain.SysDept; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +24,10 @@ import com.bonus.material.basic.service.IBmUnitPersonService; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + /** * 往来单位管理Controller * @@ -34,13 +42,35 @@ public class BmUnitPersonController extends BaseController @Autowired private IBmUnitPersonService bmUnitPersonService; + @Resource + private RemoteUserService remoteUserService; + /** - * 查询部门用户下拉树 + * 查询部门下拉树 */ - @ApiOperation(value = "查询部门用户下拉树") + @ApiOperation(value = "查询部门下拉树") @GetMapping("/getDeptUserTree") - public AjaxResult selectDeptTree(BmUnitPerson unitPerson) { - return bmUnitPersonService.selectDeptTree(unitPerson); + public AjaxResult selectDeptTree(SysDept dept) { + AjaxResult ajaxResult = remoteUserService.deptTree(dept, null); + List data = (List) ajaxResult.get("data"); + if (CollectionUtils.isEmpty(data)) { + return AjaxResult.success(); + } + List branches = getBranches(data); + return AjaxResult.success(branches); + } + + private List getBranches(List data) { + List branches = new ArrayList<>(); + for (TreeSelect company : data) { + if (company.getChildren() != null) { + for (TreeSelect child : company.getChildren()) { + // 添加分公司 + branches.add(child); + } + } + } + return branches; } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmUnitPersonMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmUnitPersonMapper.java index a43511b0..c6fbb717 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmUnitPersonMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmUnitPersonMapper.java @@ -2,7 +2,6 @@ package com.bonus.material.basic.mapper; import java.util.List; -import com.bonus.common.biz.domain.SysDeptTree; import com.bonus.common.biz.domain.TreeNode; import com.bonus.material.basic.domain.BmUnitPerson; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java index 5f55be29..593bdc44 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java @@ -76,10 +76,10 @@ public class PartTypeController extends BaseController */ @ApiOperation(value = "获取配件类型管理详细信息") @RequiresPermissions("ma:type:query") - @GetMapping(value = "/{paId}") - public AjaxResult getInfo(@PathVariable("paId") Long paId) + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { - return success(partTypeService.selectPartTypeByPaId(paId)); + return AjaxResult.success(partTypeService.selectPartTypeByPaId(id)); } /** @@ -92,7 +92,7 @@ public class PartTypeController extends BaseController @PostMapping public AjaxResult add(@RequestBody PartType partType) { - return toAjax(partTypeService.insertPartType(partType)); + return partTypeService.insertPartType(partType); } /** @@ -105,7 +105,7 @@ public class PartTypeController extends BaseController @PutMapping public AjaxResult edit(@RequestBody PartType partType) { - return toAjax(partTypeService.updatePartType(partType)); + return partTypeService.updatePartType(partType); } /** @@ -115,9 +115,9 @@ public class PartTypeController extends BaseController @PreventRepeatSubmit @RequiresPermissions("ma:type:remove") @SysLog(title = "配件类型管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除配件类型管理") - @DeleteMapping("/{paIds}") - public AjaxResult remove(@PathVariable Long paId) + @DeleteMapping("/{id}") + public AjaxResult remove(@PathVariable Long id) { - return partTypeService.deletePartTypeByPaId(paId); + return partTypeService.deletePartTypeByPaId(id); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java index 0fe4788b..99d763bc 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PartType.java @@ -22,7 +22,7 @@ public class PartType extends BaseEntity private Integer isExport; /** 类型ID */ - private Long paId; + private Long id; /** 类型名称 */ @Excel(name = "名称") @@ -78,4 +78,7 @@ public class PartType extends BaseEntity @Excel(name = "备注") private String remark; + @ApiModelProperty(value = "关键字") + private String keyWord; + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java index 726bcb5a..d6c03b93 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java @@ -16,10 +16,10 @@ public interface PartTypeMapper /** * 查询配件类型管理 * - * @param paId 配件类型管理主键 + * @param id 配件类型管理主键 * @return 配件类型管理 */ - public PartType selectPartTypeByPaId(Long paId); + public PartType selectPartTypeByPaId(Long id); /** * 查询配件类型管理列表 @@ -48,18 +48,10 @@ public interface PartTypeMapper /** * 删除配件类型管理 * - * @param paId 配件类型管理主键 + * @param id 配件类型管理主键 * @return 结果 */ - public int deletePartTypeByPaId(Long paId); - - /** - * 批量删除配件类型管理 - * - * @param paIds 需要删除的数据主键集合 - * @return 结果 - */ - public int deletePartTypeByPaIds(Long paIds); + public int deletePartTypeByPaId(Long id); /** * 获取配件类型树 @@ -74,4 +66,25 @@ public interface PartTypeMapper * @return */ List getTypeList(PartType partType); + + /** + * 根据名称查询 + * @param partType + * @return + */ + PartType selectByName(PartType partType); + + /** + * 根据id查询 + * @param id + * @return + */ + int selectById(Long id); + + /** + * 查询配件是否在用 + * @param id + * @return + */ + int selectPart(Long id); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java index a4882ec3..8255fc1a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java @@ -16,10 +16,10 @@ public interface IPartTypeService /** * 查询配件类型管理 * - * @param paId 配件类型管理主键 + * @param id 配件类型管理主键 * @return 配件类型管理 */ - public PartType selectPartTypeByPaId(Long paId); + public PartType selectPartTypeByPaId(Long id); /** * 查询配件类型管理列表 @@ -35,7 +35,7 @@ public interface IPartTypeService * @param partType 配件类型管理 * @return 结果 */ - public int insertPartType(PartType partType); + public AjaxResult insertPartType(PartType partType); /** * 修改配件类型管理 @@ -43,23 +43,15 @@ public interface IPartTypeService * @param partType 配件类型管理 * @return 结果 */ - public int updatePartType(PartType partType); - - /** - * 批量删除配件类型管理 - * - * @param paIds 需要删除的配件类型管理主键集合 - * @return 结果 - */ - public int deletePartTypeByPaIds(Long paIds); + public AjaxResult updatePartType(PartType partType); /** * 删除配件类型管理信息 * - * @param paId 配件类型管理主键 + * @param id 配件类型管理主键 * @return 结果 */ - public AjaxResult deletePartTypeByPaId(Long paId); + public AjaxResult deletePartTypeByPaId(Long id); /** * 获取配件类型树 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java index ae3195d9..ac12c538 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java @@ -2,12 +2,14 @@ package com.bonus.material.ma.service.impl; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import com.bonus.common.biz.domain.TreeBuild; import com.bonus.common.biz.domain.TreeNode; import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.security.utils.SecurityUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -32,13 +34,13 @@ public class PartTypeServiceImpl implements IPartTypeService /** * 查询配件类型管理 * - * @param paId 配件类型管理主键 + * @param id 配件类型管理主键 * @return 配件类型管理 */ @Override - public PartType selectPartTypeByPaId(Long paId) + public PartType selectPartTypeByPaId(Long id) { - return partTypeMapper.selectPartTypeByPaId(paId); + return partTypeMapper.selectPartTypeByPaId(id); } /** @@ -73,10 +75,25 @@ public class PartTypeServiceImpl implements IPartTypeService * @return 结果 */ @Override - public int insertPartType(PartType partType) + public AjaxResult insertPartType(PartType partType) { + if (partType == null || partType.getPaName() == null) { + return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg()); + } + //新增判重,二级和三级不同类型下面可以重复,一级不能重复 + PartType type = partTypeMapper.selectByName(partType); + if (type != null) { + return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg()); + } partType.setCreateTime(DateUtils.getNowDate()); - return partTypeMapper.insertPartType(partType); + partType.setCreateBy(SecurityUtils.getUserId().toString()); + partType.setParentId(partType.getId() != null ? partType.getId() : 0L); + partType.setLevel(partType.getLevel() != null ? String.valueOf(Integer.valueOf(partType.getLevel()) + 1) : "1"); + int result = partTypeMapper.insertPartType(partType); + if (result > 0) { + return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } /** @@ -86,34 +103,47 @@ public class PartTypeServiceImpl implements IPartTypeService * @return 结果 */ @Override - public int updatePartType(PartType partType) + public AjaxResult updatePartType(PartType partType) { + if (partType == null || partType.getPaName() == null || partType.getParentId() == null || partType.getId() == null) { + return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg()); + } + //修改判重,二级和三级不同类型下面可以重复,一级不能重复 + PartType type = partTypeMapper.selectByName(partType); + if (type != null) { + if (!Objects.equals(type.getId(), partType.getId())) { + return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg()); + } + } partType.setUpdateTime(DateUtils.getNowDate()); - return partTypeMapper.updatePartType(partType); - } - - /** - * 批量删除配件类型管理 - * - * @param paId 需要删除的配件类型管理主键 - * @return 结果 - */ - @Override - public int deletePartTypeByPaIds(Long paId) - { - return partTypeMapper.deletePartTypeByPaIds(paId); + partType.setUpdateBy(SecurityUtils.getUserId().toString()); + int result = partTypeMapper.updatePartType(partType); + if (result > 0) { + return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } /** * 删除配件类型管理信息 * - * @param paId 配件类型管理主键 + * @param id 配件类型管理主键 * @return 结果 */ @Override - public AjaxResult deletePartTypeByPaId(Long paId) + public AjaxResult deletePartTypeByPaId(Long id) { - int result = partTypeMapper.deletePartTypeByPaId(paId); + //判断配件类型下是否有下级配件 + int count = partTypeMapper.selectById(id); + if (count > 0) { + return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "该类型下有下级配件,不允许删除"); + } + //判断配件是否在用,在用则不能删除 + int i = partTypeMapper.selectPart(id); + if (i > 0) { + return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "该配件类型处于在用状态,不允许删除"); + } + int result = partTypeMapper.deletePartTypeByPaId(id); if (result > 0) { return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result); } @@ -153,5 +183,4 @@ public class PartTypeServiceImpl implements IPartTypeService return partTypeMapper.getTypeList(partType); } - } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml index 171bed0c..934c1917 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml @@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -24,12 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select pa_id, pa_name, parent_id, status, storage_num, unit_id, buy_price, level, warn_num, del_flag, create_by, update_by, create_time, update_time, remark, company_id, year from ma_part_type + select pa_id, pa_name, parent_id, status, storage_num, unit_id, unit_name, buy_price, level, warn_num, del_flag, create_by, update_by, create_time, update_time, remark, company_id, year from ma_part_type select pa_id as id, pa_name as label, parent_id as parentId, storage_num as storageNum, unit_name as unitName, buy_price as buyPrice, level as level, remark as remark from ma_part_type - where - - AND pa_name like concat('%', #{paName}, '%') - + where del_flag = '0' + + and ( + pa_name like concat('%', #{keyWord}, '%') + or storage_num like concat('%', #{keyWord}, '%') + or unit_name = #{keyWord}, + or buy_price like concat('%', #{keyWord}, '%') + ) + + + + + + + @@ -66,10 +96,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status, storage_num, unit_id, + unit_name, buy_price, level, warn_num, - del_flag, + del_flag, create_by, update_by, create_time, @@ -84,10 +115,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{storageNum}, #{unitId}, + #{unitName}, #{buyPrice}, #{level}, #{warnNum}, - #{delFlag}, + 0, #{createBy}, #{updateBy}, #{createTime}, @@ -106,29 +138,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status = #{status}, storage_num = #{storageNum}, unit_id = #{unitId}, + unit_name = #{unitName}, buy_price = #{buyPrice}, level = #{level}, warn_num = #{warnNum}, - del_flag = #{delFlag}, - create_by = #{createBy}, update_by = #{updateBy}, - create_time = #{createTime}, update_time = #{updateTime}, remark = #{remark}, company_id = #{companyId}, year = #{year}, - where pa_id = #{paId} + where pa_id = #{id} - update ma_part_type set del_flag = '2' where pa_id = #{paId} + update ma_part_type set del_flag = '2' where pa_id = #{id} - - update ma_part_type set del_flag = '2' where pa_id in - - #{paId} - - \ No newline at end of file