From cdcba68d850b574ff87e75e1239bef28eed3b041 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Wed, 16 Oct 2024 19:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84=E9=85=8D=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86--=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91=E6=8A=BD?= =?UTF-8?q?=E7=A6=BB=EF=BC=8C=E9=81=8D=E5=8E=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/MaTypeConfigController.java | 73 ++++++---------- .../ma/service/MaTypeConfigService.java | 18 ++++ .../service/impl/MaTypeConfigServiceImpl.java | 85 +++++++++++++++++++ 3 files changed, 131 insertions(+), 45 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/MaTypeConfigService.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MaTypeConfigServiceImpl.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java index c7fdfeb8..aff20f32 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java @@ -12,6 +12,7 @@ import com.bonus.material.ma.domain.TypeRepair; import com.bonus.material.ma.service.ITypeKeeperService; import com.bonus.material.ma.service.ITypeRepairService; import com.bonus.material.ma.service.ITypeService; +import com.bonus.material.ma.service.MaTypeConfigService; import com.bonus.material.ma.vo.MaTypeConfigVo; import com.google.common.collect.ImmutableList; import io.swagger.annotations.Api; @@ -55,6 +56,9 @@ public class MaTypeConfigController extends BaseController { private ITypeService typeService; + @Resource + private MaTypeConfigService maTypeConfigService; + @ApiOperation(value = "配置物资类型绑定信息") @PreventRepeatSubmit @RequiresPermissions("ma:typeConfig:edit") @@ -66,62 +70,19 @@ public class MaTypeConfigController extends BaseController { if (maTypeConfigDto.getBindFlag() == null) { return error("绑定标识不能为空"); } - // 2.判断绑定角色类型是否为空 if (maTypeConfigDto.getBindRoleType() == null) { return error("绑定角色类型不能为空"); } - // 3.判断用户id是否为空 if (maTypeConfigDto.getUserId() == null) { return error("用户id不能为空"); } // ---------------- 数据校验结束 --------------------- - int result; - switch (maTypeConfigDto.getBindFlag()) { - case 1: - result = handleBind(maTypeConfigDto.getBindFlag(), maTypeConfigDto.getTypeId(), maTypeConfigDto.getUserId()); - return result == 1 ? AjaxResult.success("绑定成功") : error("绑定失败"); - case 2: - result = handleUnBind(maTypeConfigDto.getBindFlag(), maTypeConfigDto.getTypeId(), maTypeConfigDto.getUserId()); - return result == 1 ? AjaxResult.success("解绑成功") : error("解绑失败"); - default: - // 处理其他情况或抛出异常 - return error("输入值不合法 bindFlag: " + maTypeConfigDto.getBindFlag()); - } - } - private int handleBind(int bindRoleType, Long typeId, Long userId) { - switch (bindRoleType) { - case 1: - // 处理 bindFlag 为 1:绑定 且 bindRoleType 为 1:库管员 的情况 - // TODO: 实现具体逻辑 - return typeKeeperService.insertTypeKeeper(new TypeKeeper(typeId, userId)); - case 2: - // 处理 bindFlag 为 1:绑定 且 bindRoleType 为 2:维修员 的情况 - // TODO: 实现具体逻辑 - return typeRepairService.insertTypeRepair(new TypeRepair(typeId, userId)); - default: - // 处理其他情况或抛出异常 - throw new IllegalArgumentException("Unsupported bindRoleType: " + bindRoleType); - } - } - - private int handleUnBind(int bindRoleType, Long typeId, Long userId) { - switch (bindRoleType) { - case 1: - // 处理 bindFlag 为 2:解绑 且 bindRoleType 为 1:库管员 的情况 - // TODO: 实现具体逻辑 - return typeKeeperService.deleteTypeKeeperByUserIdAndTypeId(new TypeKeeper(typeId, userId)); - case 2: - // 处理 bindFlag 为 2:解绑 且 bindRoleType 为 2:维修员 的情况 - // TODO: 实现具体逻辑 - return typeRepairService.deleteTypeRepairByUserIdAndTypeId(new TypeRepair(typeId, userId)); - default: - // 处理其他情况或抛出异常 - throw new IllegalArgumentException("Unsupported bindRoleType: " + bindRoleType); - } + // 执行业务逻辑 + return maTypeConfigService.updateMaTypeBindInfo(maTypeConfigDto); } @@ -152,6 +113,17 @@ public class MaTypeConfigController extends BaseController { maTypeConfigVo1.setRepairUserId(typeRepair.getUserId()); maTypeConfigVo1.setRepairUserName(typeRepair.getUserName()); } + // 判断当前maTypeConfigVo1对象是否有子节点,如果有再继续循环 + if (maTypeConfigVo1.getChildren() != null) { + for (MaTypeConfigVo maTypeConfigVo2 : maTypeConfigVo1.getChildren()) { + // 5.判断当前维修配置信息中的物资类型id是否等于当前物资类型配置信息中的物资类型id + if (typeRepair.getTypeId().equals(maTypeConfigVo2.getTypeId())) { + // 6.如果相等,把维修员信息设置到物资类型配置信息中 + maTypeConfigVo2.setRepairUserId(typeRepair.getUserId()); + maTypeConfigVo2.setRepairUserName(typeRepair.getUserName()); + } + } + } } } @@ -165,6 +137,17 @@ public class MaTypeConfigController extends BaseController { maTypeConfigVo1.setKeeperUserId(typeKeeper.getUserId()); maTypeConfigVo1.setKeeperUserName(typeKeeper.getUserName()); } + // 判断当前maTypeConfigVo1对象是否有子节点,如果有再继续循环 + if (maTypeConfigVo1.getChildren() != null) { + for (MaTypeConfigVo maTypeConfigVo2 : maTypeConfigVo1.getChildren()) { + // 5.判断当前库管配置信息中的物资类型id是否等于当前物资类型配置信息中的物资类型id + if (typeKeeper.getTypeId().equals(maTypeConfigVo2.getTypeId())) { + // 6.如果相等,把库管员信息设置到物资类型配置信息中 + maTypeConfigVo2.setKeeperUserId(typeKeeper.getUserId()); + maTypeConfigVo2.setKeeperUserName(typeKeeper.getUserName()); + } + } + } } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/MaTypeConfigService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/MaTypeConfigService.java new file mode 100644 index 00000000..c915d30f --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/MaTypeConfigService.java @@ -0,0 +1,18 @@ +package com.bonus.material.ma.service; + +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.ma.MaTypeConfigDto; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.ma.service + * @CreateTime: 2024-10-16 18:50 + * @Description: 物资类型配置Service + */ +public interface MaTypeConfigService{ + + AjaxResult updateMaTypeBindInfo(MaTypeConfigDto maTypeConfigDto); + + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MaTypeConfigServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MaTypeConfigServiceImpl.java new file mode 100644 index 00000000..4d8e29ec --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MaTypeConfigServiceImpl.java @@ -0,0 +1,85 @@ +package com.bonus.material.ma.service.impl; + +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.ma.MaTypeConfigDto; +import com.bonus.material.ma.domain.TypeKeeper; +import com.bonus.material.ma.domain.TypeRepair; +import com.bonus.material.ma.service.ITypeKeeperService; +import com.bonus.material.ma.service.ITypeRepairService; +import com.bonus.material.ma.service.MaTypeConfigService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.ma.service.impl + * @CreateTime: 2024-10-16 18:50 + * @Description: 描述 + */ +@Service +public class MaTypeConfigServiceImpl implements MaTypeConfigService { + + /** + * 物资类型库管员配置Service + */ + @Resource + private ITypeKeeperService typeKeeperService; + + /** + * 物资类型维修员配置Service + */ + @Resource + private ITypeRepairService typeRepairService; + + + @Override + public AjaxResult updateMaTypeBindInfo(MaTypeConfigDto maTypeConfigDto) { + int result; + switch (maTypeConfigDto.getBindFlag()) { + case 1: + result = handleBind(maTypeConfigDto.getBindFlag(), maTypeConfigDto.getTypeId(), maTypeConfigDto.getUserId()); + return result == 1 ? AjaxResult.success("绑定成功") : AjaxResult.error("绑定失败"); + case 2: + result = handleUnBind(maTypeConfigDto.getBindFlag(), maTypeConfigDto.getTypeId(), maTypeConfigDto.getUserId()); + return result == 1 ? AjaxResult.success("解绑成功") : AjaxResult.error("解绑失败"); + default: + // 处理其他情况或抛出异常 + return AjaxResult.error("输入值不合法 bindFlag: " + maTypeConfigDto.getBindFlag()); + } + } + + + private int handleBind(int bindRoleType, Long typeId, Long userId) { + switch (bindRoleType) { + case 1: + // 处理 bindFlag 为 1:绑定 且 bindRoleType 为 1:库管员 的情况 + // TODO: 实现具体逻辑 + return typeKeeperService.insertTypeKeeper(new TypeKeeper(typeId, userId)); + case 2: + // 处理 bindFlag 为 1:绑定 且 bindRoleType 为 2:维修员 的情况 + // TODO: 实现具体逻辑 + return typeRepairService.insertTypeRepair(new TypeRepair(typeId, userId)); + default: + // 处理其他情况或抛出异常 + throw new IllegalArgumentException("Unsupported bindRoleType: " + bindRoleType); + } + } + + private int handleUnBind(int bindRoleType, Long typeId, Long userId) { + switch (bindRoleType) { + case 1: + // 处理 bindFlag 为 2:解绑 且 bindRoleType 为 1:库管员 的情况 + // TODO: 实现具体逻辑 + return typeKeeperService.deleteTypeKeeperByUserIdAndTypeId(new TypeKeeper(typeId, userId)); + case 2: + // 处理 bindFlag 为 2:解绑 且 bindRoleType 为 2:维修员 的情况 + // TODO: 实现具体逻辑 + return typeRepairService.deleteTypeRepairByUserIdAndTypeId(new TypeRepair(typeId, userId)); + default: + // 处理其他情况或抛出异常 + throw new IllegalArgumentException("Unsupported bindRoleType: " + bindRoleType); + } + } +}