配件库管绑定
This commit is contained in:
parent
97ce2b0e6f
commit
c212a6401e
|
|
@ -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,8 +77,13 @@ public class PartTypeController extends BaseController
|
|||
for (Integer parentId : parentIds) {
|
||||
maTypeVos.addAll(partTypeService.getListByParentId(parentId.longValue(), partType));
|
||||
}
|
||||
if (BooleanUtils.isTrue(partType.getDisplayBindRelationship())) {
|
||||
List<PartType> finalMaTypeVos = partTypeService.getMyTypeAndBindUsers(maTypeVos);
|
||||
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, finalMaTypeVos));
|
||||
} else {
|
||||
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, maTypeVos));
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "配件类型所属上级树")
|
||||
@RequiresPermissions("ma:type:query")
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,4 +118,11 @@ public interface PartTypeMapper
|
|||
* @return
|
||||
*/
|
||||
List<PartLeaseDetails> getPersonStorageNumList(PartLeaseDetails bean);
|
||||
|
||||
/**
|
||||
* 获取当前配件库管员
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
PartType getUserName(PartType partType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,4 +85,11 @@ public interface IPartTypeService
|
|||
* @return
|
||||
*/
|
||||
List<PartLeaseDetails> getPersonStorageNumList(PartLeaseDetails bean);
|
||||
|
||||
/**
|
||||
* 获取当前配件库管员
|
||||
* @param maTypeVos
|
||||
* @return
|
||||
*/
|
||||
List<PartType> getMyTypeAndBindUsers(List<PartType> maTypeVos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,4 +253,24 @@ public class PartTypeServiceImpl implements IPartTypeService
|
|||
public List<PartLeaseDetails> getPersonStorageNumList(PartLeaseDetails bean) {
|
||||
return partTypeMapper.getPersonStorageNumList(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前配件库管员
|
||||
* @param maTypeVos
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PartType> getMyTypeAndBindUsers(List<PartType> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<MaPartTypeKeeper> typeKeepers) {
|
||||
try {
|
||||
return partLeaseService.deleteTypeKeeper(typeKeepers);
|
||||
} catch (Exception e) {
|
||||
return error("解绑失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Long> typeIds;
|
||||
|
||||
}
|
||||
|
|
@ -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<MaPartTypeKeeper> selectTypeKeeperByTypeId(Long typeId);
|
||||
|
||||
/**
|
||||
* 查询配件库管关系
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
List<PartType> selectUserList(PartType partType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<MaPartTypeKeeper> typeKeepers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<PartType> list = new ArrayList<>();
|
||||
List<PartType> secondList = new ArrayList<>();
|
||||
List<PartType> thirdList = new ArrayList<>();
|
||||
HashMap<String, Object> map = new HashMap<>(2);
|
||||
List<PartType> partTypeList = partLeaseMapper.selectPartTreeList(partType);
|
||||
//List<PartType> partTypeList = partLeaseMapper.selectPartTreeList(partType);
|
||||
List<PartType> partTypeList = partLeaseMapper.selectUserList(partType);
|
||||
if (!CollectionUtils.isEmpty(partTypeList)) {
|
||||
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.addAll(partTypeList);
|
||||
partTypeList.forEach(partType1 -> {
|
||||
PartType type = new PartType();
|
||||
type.setId(partType1.getId());
|
||||
List<PartType> partTypeList1 = partLeaseMapper.selectPartTreeList(type);
|
||||
List<PartType> 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<MaPartTypeKeeper> 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<MaPartTypeKeeper> 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("解绑成功");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
and mt2.pa_id = #{id}
|
||||
</if>
|
||||
and mt2.pa_id is not null
|
||||
and mt2.del_flag = '0'
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
@ -268,4 +269,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getUserName" resultType="com.bonus.material.ma.domain.PartType">
|
||||
SELECT
|
||||
mp.user_id AS userId,
|
||||
su.nick_name AS keepUserName
|
||||
FROM
|
||||
ma_part_type_keeper mp
|
||||
LEFT JOIN sys_user su ON mp.user_id = su.user_id
|
||||
WHERE
|
||||
mp.type_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -195,6 +195,50 @@
|
|||
part_id = #{partId}
|
||||
AND creator = #{createBy}
|
||||
</select>
|
||||
<select id="selectTypeKeeperByTypeId" resultType="com.bonus.material.part.domain.MaPartTypeKeeper">
|
||||
SELECT
|
||||
type_id as typeId,
|
||||
user_id as userId
|
||||
FROM
|
||||
ma_part_type_keeper
|
||||
WHERE
|
||||
type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
<select id="selectUserList" resultType="com.bonus.material.ma.domain.PartType">
|
||||
SELECT DISTINCT
|
||||
m.pa_id AS thirdId,
|
||||
m.pa_name AS paName,
|
||||
m1.pa_id AS secondId,
|
||||
m1.pa_name AS partName,
|
||||
m1.LEVEL AS secondLevel,
|
||||
m2.pa_id AS firstId,
|
||||
m2.pa_name As partType,
|
||||
m2.LEVEL AS firstLevel,
|
||||
m.parent_id as parentId,
|
||||
m.unit_name as unitName,
|
||||
m.storage_num as storageNum,
|
||||
m.buy_price as buyPrice,
|
||||
m.LEVEL as thirdLevel,
|
||||
m.remark as remark
|
||||
FROM
|
||||
ma_part_type m
|
||||
LEFT JOIN ma_part_type m1 ON m.parent_id = m1.pa_id
|
||||
and m1.del_flag = '0'
|
||||
LEFT JOIN ma_part_type m2 ON m1.parent_id = m2.pa_id
|
||||
and m2.del_flag = '0'
|
||||
<if test="userId != null">
|
||||
right join ma_part_type_keeper mp ON m.pa_id = mp.type_id
|
||||
and mp.user_id = #{userId}
|
||||
</if>
|
||||
WHERE m.del_flag = '0'
|
||||
<if test="level == 2 and id != null">
|
||||
and m1.parent_id = #{id}
|
||||
</if>
|
||||
<if test="level == 3 and id != null">
|
||||
and m.parent_id = #{id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertPartLeaseDetails">
|
||||
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>
|
||||
|
||||
<insert id="insertTypeKeeper">
|
||||
insert into ma_part_type_keeper(type_id, user_id, create_by, create_time)
|
||||
values
|
||||
(#{typeId}, #{userId}, #{createBy}, #{createTime})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteTypeKeeper">
|
||||
delete from ma_part_type_keeper where type_id = #{typeId} and user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
<update id="updatePartLeaseInfo">
|
||||
update pa_collar_apply
|
||||
<set>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue