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 02fbb7f0..675a966b 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 @@ -14,6 +14,7 @@ import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.material.part.domain.PartLeaseDetails; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.BooleanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.GetMapping; @@ -76,7 +77,12 @@ public class PartTypeController extends BaseController for (Integer parentId : parentIds) { maTypeVos.addAll(partTypeService.getListByParentId(parentId.longValue(), partType)); } - return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, maTypeVos)); + if (BooleanUtils.isTrue(partType.getDisplayBindRelationship())) { + List finalMaTypeVos = partTypeService.getMyTypeAndBindUsers(maTypeVos); + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, finalMaTypeVos)); + } else { + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, maTypeVos)); + } } @ApiOperation(value = "配件类型所属上级树") 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 00bcec80..830943a9 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 @@ -97,4 +97,35 @@ public class PartType extends BaseEntity @ApiModelProperty(value = "关键字") private String keyWord; + @ApiModelProperty(value = "是否显示绑定关系") + private Boolean displayBindRelationship; + + /** 库管员id */ + @ApiModelProperty(value = "库管员id") + private Long userId; + + @ApiModelProperty(value = "库管员") + private String keepUserName; + + /** 一级类型ID */ + private Long firstId; + + /** 二级类型ID */ + private Long secondId; + + /** 三级类型ID */ + private Long thirdId; + + /** 一级层级 */ + @ApiModelProperty(value = "一级层级") + private String firstLevel; + + /** 二级层级 */ + @ApiModelProperty(value = "二级层级") + private String secondLevel; + + /** 三级层级 */ + @ApiModelProperty(value = "三级层级") + private String thirdLevel; + } 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 5e7bae81..059923c1 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 @@ -118,4 +118,11 @@ public interface PartTypeMapper * @return */ List getPersonStorageNumList(PartLeaseDetails bean); + + /** + * 获取当前配件库管员 + * @param partType + * @return + */ + PartType getUserName(PartType partType); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java index 1dbff7b9..860d8bcf 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 @@ -85,4 +85,11 @@ public interface IPartTypeService * @return */ List getPersonStorageNumList(PartLeaseDetails bean); + + /** + * 获取当前配件库管员 + * @param maTypeVos + * @return + */ + List getMyTypeAndBindUsers(List maTypeVos); } 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 8ea11a97..fa966306 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 @@ -253,4 +253,24 @@ public class PartTypeServiceImpl implements IPartTypeService public List getPersonStorageNumList(PartLeaseDetails bean) { return partTypeMapper.getPersonStorageNumList(bean); } + + /** + * 获取当前配件库管员 + * @param maTypeVos + * @return + */ + @Override + public List getMyTypeAndBindUsers(List maTypeVos) { + if (!CollectionUtils.isEmpty(maTypeVos)) { + for (PartType partType : maTypeVos) { + // 根据id查询绑定库管员 + PartType type = partTypeMapper.getUserName(partType); + if (type != null) { + partType.setKeepUserName(type.getKeepUserName()); + partType.setUserId(type.getUserId()); + } + } + } + return maTypeVos; + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/controller/PartLeaseController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/controller/PartLeaseController.java index 9a45e2d8..a0ca6503 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/controller/PartLeaseController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/controller/PartLeaseController.java @@ -6,7 +6,9 @@ import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.material.ma.domain.PartType; +import com.bonus.material.part.domain.MaPartTypeKeeper; import com.bonus.material.part.domain.PartLeaseDetails; import com.bonus.material.part.domain.PartLeaseInfo; import com.bonus.material.part.service.PartLeaseService; @@ -97,4 +99,32 @@ public class PartLeaseController extends BaseController { return partLeaseService.auditPartLeaseInfo(partLeaseInfo); } + /** + * 新增库管员配置 + */ + @ApiOperation(value = "新增配件库管员配置") + @PreventRepeatSubmit + @PostMapping("/add") + public AjaxResult add(@RequestBody MaPartTypeKeeper typeKeepers) { + try { + return partLeaseService.insertTypeKeeper(typeKeepers); + } catch (Exception e) { + return error("绑定失败,请联系管理员"); + } + } + + /** + * 解绑配件库管员配置 + */ + @ApiOperation(value = "解绑配件库管员配置") + @PreventRepeatSubmit + @PostMapping("/unBind") + public AjaxResult unBind(@RequestBody List typeKeepers) { + try { + return partLeaseService.deleteTypeKeeper(typeKeepers); + } catch (Exception e) { + return error("解绑失败,请联系管理员"); + } + } + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/domain/MaPartTypeKeeper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/domain/MaPartTypeKeeper.java new file mode 100644 index 00000000..9f265667 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/domain/MaPartTypeKeeper.java @@ -0,0 +1,40 @@ +package com.bonus.material.part.domain; + +import com.bonus.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 配件库管绑定 + * @Author ma_sh + * @create 2025/6/16 10:13 + */ +@Data +public class MaPartTypeKeeper extends BaseEntity { + + private static final long serialVersionUID = -5333521595576336827L; + + /** 主键ID */ + private Long id; + + /** 配件类型ID */ + private Long typeId; + + /** 用户 */ + @ApiModelProperty(value = "用户ID") + private Long userId; + + /** 用户名称 */ + @ApiModelProperty(value = "用户名称") + private String userName; + + /** 数据所属组织 */ + @ApiModelProperty(value = "数据所属组织") + private String companyId; + + /** 配件类型ID集合 */ + private List typeIds; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/mapper/PartLeaseMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/mapper/PartLeaseMapper.java index c21361b7..cf05a843 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/mapper/PartLeaseMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/mapper/PartLeaseMapper.java @@ -1,6 +1,7 @@ package com.bonus.material.part.mapper; import com.bonus.material.ma.domain.PartType; +import com.bonus.material.part.domain.MaPartTypeKeeper; import com.bonus.material.part.domain.PartLeaseDetails; import com.bonus.material.part.domain.PartLeaseInfo; import org.apache.ibatis.annotations.Mapper; @@ -136,4 +137,32 @@ public interface PartLeaseMapper { * @return */ int updateTaskStatus(@Param("taskId") String taskId,@Param("status") Integer status); + + /** + * 新增配件库管员配置 + * @param typeKeepers + * @return + */ + int insertTypeKeeper(MaPartTypeKeeper typeKeepers); + + /** + * 删除配件库管员配置 + * @param typeKeeper + * @return + */ + int deleteTypeKeeper(MaPartTypeKeeper typeKeeper); + + /** + * 查询配件库管员配置 + * @param typeId + * @return + */ + List selectTypeKeeperByTypeId(Long typeId); + + /** + * 查询配件库管关系 + * @param partType + * @return + */ + List selectUserList(PartType partType); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/PartLeaseService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/PartLeaseService.java index ca208bb5..952b2f34 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/PartLeaseService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/PartLeaseService.java @@ -2,6 +2,7 @@ package com.bonus.material.part.service; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.ma.domain.PartType; +import com.bonus.material.part.domain.MaPartTypeKeeper; import com.bonus.material.part.domain.PartLeaseDetails; import com.bonus.material.part.domain.PartLeaseInfo; import com.bonus.material.part.domain.vo.PartLeaseVo; @@ -58,4 +59,18 @@ public interface PartLeaseService { * @return */ AjaxResult selectPartTreeListByLevel(PartType partType); + + /** + * 新增库管员配置 + * @param typeKeepers + * @return + */ + AjaxResult insertTypeKeeper(MaPartTypeKeeper typeKeepers); + + /** + * 解绑配件库管员配置 + * @param typeKeepers + * @return + */ + AjaxResult deleteTypeKeeper(List typeKeepers); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/impl/PartLeaseServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/impl/PartLeaseServiceImpl.java index 7b379553..871c339b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/impl/PartLeaseServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/part/service/impl/PartLeaseServiceImpl.java @@ -10,6 +10,7 @@ import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.ma.domain.PartType; +import com.bonus.material.part.domain.MaPartTypeKeeper; import com.bonus.material.part.domain.PartLeaseDetails; import com.bonus.material.part.domain.PartLeaseInfo; import com.bonus.material.part.domain.vo.PartLeaseVo; @@ -159,29 +160,84 @@ public class PartLeaseServiceImpl implements PartLeaseService { */ @Override public AjaxResult selectPartTreeList(PartType partType) { + //获取当前用户ID + Long userId = SecurityUtils.getLoginUser().getUserid(); + partType.setUserId(userId); List list = new ArrayList<>(); List secondList = new ArrayList<>(); List thirdList = new ArrayList<>(); HashMap map = new HashMap<>(2); - List partTypeList = partLeaseMapper.selectPartTreeList(partType); + //List partTypeList = partLeaseMapper.selectPartTreeList(partType); + List partTypeList = partLeaseMapper.selectUserList(partType); if (!CollectionUtils.isEmpty(partTypeList)) { - if (partType.getId() != null) { - list.addAll(partTypeList); - partTypeList.forEach(partType1 -> { - PartType type = new PartType(); - type.setId(partType1.getId()); - List partTypeList1 = partLeaseMapper.selectPartTreeList(type); - if (!CollectionUtils.isEmpty(partTypeList1)) { - list.addAll(partTypeList1); + if ("1".equals(partType.getLevel())) { + // 获取partTypeList中的level为1的数据 + for (PartType type : partTypeList) { + PartType type1 = new PartType(); + type1.setId(type.getFirstId()); + type1.setPaName(type.getPartType()); + // 先判断list集合中是否包含该数据 + if (!list.contains(type1)) { + list.add(type1); } - }); + } + return AjaxResult.success(list); + } + if ("2".equals(partType.getLevel()) && partType.getId() == null) { + // 获取partTypeList中的level为2的数据 + for (PartType type : partTypeList) { + PartType type1 = new PartType(); + type1.setId(type.getSecondId()); + type1.setPaName(type.getPartName()); + // 先判断list集合中是否包含该数据 + if (!list.contains(type1)) { + list.add(type1); + } + } + return AjaxResult.success(list); + } + if ("3".equals(partType.getLevel()) && partType.getId() == null) { + // 获取partTypeList中的level为3的数据 + for (PartType type : partTypeList) { + PartType type1 = new PartType(); + type1.setId(type.getThirdId()); + type1.setPaName(type.getPaName()); + type1.setStorageNum(type.getStorageNum()); + type1.setUnitName(type.getUnitName()); + // 先判断list集合中是否包含该数据 + if (!list.contains(type1)) { + list.add(type1); + } + } + return AjaxResult.success(list); + } + if (partType.getId() != null) { + List partTypeList1 = partLeaseMapper.selectUserList(partType); + if (!CollectionUtils.isEmpty(partTypeList1)) { + list.addAll(partTypeList1); + } } if (!CollectionUtils.isEmpty(list)) { + // 从list获取secondLevel为2的数据,并去重放到secondList中 for (PartType type : list) { - if ("2".equals(type.getLevel())) { - secondList.add(type); - } else if ("3".equals(type.getLevel())) { - thirdList.add(type); + if ("2".equals(type.getSecondLevel())) { + PartType type1 = new PartType(); + type1.setId(type.getSecondId()); + type1.setPaName(type.getPartName()); + if (!secondList.contains(type1)) { + secondList.add(type1); + } + } + if ("3".equals(type.getThirdLevel())) { + PartType type1 = new PartType(); + type1.setId(type.getThirdId()); + type1.setPaName(type.getPaName()); + type1.setLevel(type.getThirdLevel()); + type1.setUnitName(type.getUnitName()); + type1.setStorageNum(type.getStorageNum()); + if (!thirdList.contains(type1)) { + thirdList.add(type1); + } } } map.put("secondList", secondList); @@ -304,4 +360,55 @@ public class PartLeaseServiceImpl implements PartLeaseService { } return AjaxResult.success(list); } + + /** + * 新增库管员配置 + * @param typeKeepers + * @return + */ + @Override + public AjaxResult insertTypeKeeper(MaPartTypeKeeper typeKeepers) { + if (typeKeepers == null) { + return AjaxResult.error("参数不能为空"); + } + if (!CollectionUtils.isEmpty(typeKeepers.getTypeIds())) { + for (Long typeId : typeKeepers.getTypeIds()) { + // 先根据typeId查询库管员配置是否已经存在,存在则先删除 + List list = partLeaseMapper.selectTypeKeeperByTypeId(typeId); + if (!CollectionUtils.isEmpty(list)) { + for (MaPartTypeKeeper typeKeeper : list) { + partLeaseMapper.deleteTypeKeeper(typeKeeper); + } + } + typeKeepers.setTypeId(typeId); + typeKeepers.setUserId(typeKeepers.getUserId()); + typeKeepers.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); + typeKeepers.setCreateTime(DateUtils.getNowDate()); + int res = partLeaseMapper.insertTypeKeeper(typeKeepers); + if (res == 0) { + return AjaxResult.error("绑定失败,请联系管理员"); + } + } + } + return AjaxResult.success("绑定成功"); + } + + /** + * 解绑库管员配置 + * @param typeKeepers + * @return + */ + @Override + public AjaxResult deleteTypeKeeper(List typeKeepers) { + if (CollectionUtils.isEmpty(typeKeepers)) { + return AjaxResult.error("参数不能为空"); + } + for (MaPartTypeKeeper typeKeeper : typeKeepers) { + int res = partLeaseMapper.deleteTypeKeeper(typeKeeper); + if (res == 0) { + return AjaxResult.error("解绑失败,请联系管理员"); + } + } + return AjaxResult.success("解绑成功"); + } } 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 bda2051b..039ea36c 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 @@ -169,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mt2.pa_id = #{id} and mt2.pa_id is not null + and mt2.del_flag = '0' @@ -268,4 +269,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/part/PartLeaseMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/part/PartLeaseMapper.xml index 6602dae5..0c9e65b3 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/part/PartLeaseMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/part/PartLeaseMapper.xml @@ -195,6 +195,50 @@ part_id = #{partId} AND creator = #{createBy} + + + insert into pa_collar_apply_details(task_id, part_id, pre_num, al_num, remarks) @@ -214,6 +258,16 @@ values (#{taskId}, #{partId}, #{preNum}, #{bugPrice}, #{createBy}, #{createTime}) + + insert into ma_part_type_keeper(type_id, user_id, create_by, create_time) + values + (#{typeId}, #{userId}, #{createBy}, #{createTime}) + + + + delete from ma_part_type_keeper where type_id = #{typeId} and user_id = #{userId} + + update pa_collar_apply diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml index f48a3545..94698912 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml @@ -221,15 +221,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" pcd.id AS purchaseId, mt1.type_name AS materialName, mt.type_name AS materialModel, - pcd.check_num AS purchaseNum, - pcd.check_num AS checkNum, - ifnull(pcd.bind_num,0) AS bindNum, + IFNULL(pcd.check_num, 0) AS purchaseNum, + IFNULL(pcd.check_num, 0) AS checkNum, + IFNULL(pcd.bind_num,0) AS bindNum, pcd.type_id as typeId, mt.unit_name AS unitName, ms.supplier AS supplierName, pcd.production_time AS productDate, mt.manage_type AS manageType, - pcd.`status` , + pcd.`status` AS status, pm.ma_code AS maCode, pm.out_fac_code AS outFacCode, pm.qr_code AS qrCode