宏源权限

This commit is contained in:
hongchao 2026-01-09 15:44:54 +08:00
parent de622211a4
commit 62887ff5c7
5 changed files with 159 additions and 3 deletions

View File

@ -185,6 +185,19 @@ public class TypeController extends BaseController {
return success(listByMaType);
}
/**
* 查询物资类型4级规格型号--领用申请下拉框
*
* @param typeId 规格型号
*/
@ApiOperation(value = "获取物资类型连动式下拉框")
@GetMapping("/equipmentTypeLY")
public AjaxResult equipmentTypeLY(@RequestParam(required = false) Long typeId, @RequestParam(required = false) String typeName) {
Long deptId = typeService.getUserDeptId();
List<Type> listByMaType = typeService.getEquipmentTypeLY(typeId, typeName, deptId);
return success(listByMaType);
}
/**
* 获取领用物资类型连动式下拉框
* @param typeId

View File

@ -27,6 +27,8 @@ public interface TypeMapper {
List<Type> selectMaTypeList(@Param("typeId") Long typeId, @Param("typeName") String typeName, @Param("companyId") Long companyId);
List<Type> selectMaTypeListLY(@Param("typeId") Long typeId, @Param("typeName") String typeName, @Param("companyId") Long companyId);
/**
* 查询物资类型3级--前端联动式下拉框
* 没有4级规格型号

View File

@ -29,6 +29,8 @@ public interface ITypeService {
List<Type> getEquipmentType(Long typeId, String typeName, Long deptId);
List<Type> getEquipmentTypeLY(Long typeId, String typeName, Long deptId);
/**
* 查询物资类型3级--前端联动式下拉框
* 没有4级规格型号

View File

@ -107,6 +107,27 @@ public class TypeServiceImpl implements ITypeService {
return roots;
}
/**
* 查询物资类型四级树--前端联动式下拉框
*
* @param typeId 类型id
* @param typeName 类型名称
*/
@Override
public List<Type> getEquipmentTypeLY(Long typeId, String typeName, Long deptId) {
List<Type> maTypes = typeMapper.selectMaTypeListLY(typeId, typeName, deptId);
List<Type> roots = maTypes.stream()
.filter(t -> t.getParentId() == 0)
.collect(Collectors.toList());
// 构建树并计算优先级
roots.forEach(root -> buildTreeWithPriority(root, maTypes));
// 对根节点排序含0值处理
roots.sort(this::compareNodes);
return roots;
}
/**
* 递归构建树结构并计算排序优先级
*/

View File

@ -379,7 +379,9 @@
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
where mt3.del_flag = 0 and mt3.level = 3
<if test="deptId != null ">
AND mt3.company_id = #{deptId}
</if>
UNION
select
@ -389,7 +391,9 @@
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
where mt2.del_flag = 0 and mt2.level = 2
<if test="deptId != null ">
AND mt2.company_id = #{deptId}
</if>
UNION
select
@ -398,7 +402,9 @@
from ma_type mt1
left join wh_house_set whs on mt1.type_id=whs.type_id
where mt1.del_flag = 0 and mt1.level = 1
<if test="deptId != null ">
AND mt1.company_id = #{deptId}
</if>
order by type_id
</select>
@ -620,6 +626,118 @@
</select>
<select id="selectMaTypeListLY" resultMap="TypeResult">
select DISTINCT m.type_id, m.type_name, m.parent_id, m.unit_id, m.unit_name, m.unit_value,m.manage_type,
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.sort_num,
m.del_flag, m.create_by, m.create_time,
m.remark,m.type_id id , m.type_name label,
CASE m.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(m.storage_num, 0)
END as storage_num,
m.company_id as companyId,
IFNULL(subquery1.pendingOutNum,0) as pendingOutNum,
m.jiju_type
from ma_type m
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
<if test="companyId != null and companyId !='' ">
AND CASE
WHEN (#{companyId} = 102 or #{companyId} = 327) THEN mt.company_id= 101
WHEN #{companyId} = 309 THEN (mt.company_id=#{companyId}) or (mt.company_id=101 and mt.jiju_type=1)
ELSE mt.type_id=-1
END
</if>
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = m.type_id
LEFT JOIN (
SELECT
combined.typeId AS typeId,
COALESCE ( SUM( combined.pendingOutNum ), 0 ) AS pendingOutNum
FROM
(-- 第一个查询
SELECT
lad.type_id AS typeId,
SUM( pre_num ) - SUM( al_num ) AS pendingOutNum
FROM
lease_apply_info lai
LEFT JOIN lease_apply_details lad ON lad.parent_id = lai.id
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
left join ma_type mt on lad.type_id=mt.type_id
WHERE
tt.task_status = '3'
AND tt.task_type = '2'
<if test="companyId != null and companyId !='' ">
AND CASE
WHEN (#{companyId} = 102 or #{companyId} = 327) THEN mt.company_id= 101
WHEN #{companyId} = 309 THEN (mt.company_id=#{companyId}) or (mt.company_id=101 and mt.jiju_type=1)
ELSE mt.type_id=-1
END
</if>
GROUP BY
lad.type_id UNION ALL-- 第二个查询
SELECT
lpd.new_type AS typeId,
SUM( lpd.num ) - IFNULL( lod.alNum, 0 ) AS pendingOutNum
FROM
lease_publish_details lpd
LEFT JOIN (
SELECT
lod.type_id AS typeId,
SUM( lod.out_num ) AS alNum
FROM
lease_out_details lod
left join ma_type mt on lod.type_id=mt.type_id
WHERE
publish_task IS NOT NULL
<if test="companyId != null and companyId !='' ">
AND CASE
WHEN (#{companyId} = 102 or #{companyId} = 327) THEN mt.company_id= 101
WHEN #{companyId} = 309 THEN (mt.company_id=#{companyId}) or (mt.company_id=101 and mt.jiju_type=1)
ELSE mt.type_id=-1
END
</if>
GROUP BY
lod.type_id
) lod ON lpd.new_type = lod.typeId
left join ma_type mt on lpd.new_type=mt.type_id
where 1=1
<if test="companyId != null and companyId !=''">
AND mt.company_id=#{companyId}
</if>
GROUP BY
lpd.new_type
) combined
GROUP BY
combined.typeId
) subquery1 on subquery1.typeId=m.type_id
<where>
m.del_flag = '0'
<if test="companyId != null and companyId !=''">
AND CASE
WHEN (#{companyId} = 102 or #{companyId} = 327) THEN m.company_id= 101
WHEN #{companyId} = 309 THEN (m.company_id=#{companyId}) or (m.company_id=101 and m.jiju_type=1)
ELSE m.type_id=-1
END
</if>
<if test="typeName != null and typeName !=''">
AND m.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeId != null and typeId !=''">
AND m.type_id = #{typeId}
</if>
</where>
</select>
<select id="selectMaTypeThreeList" resultMap="TypeResult">
select DISTINCT m.type_id, m.type_name, m.parent_id, m.unit_id, m.unit_name, m.unit_value,m.manage_type,
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,