Compare commits

...

5 Commits

Author SHA1 Message Date
xiaofajia
a94700e4f6 修改 2024-12-17 17:18:30 +08:00
xiaofajia
2fbbcb0daa 修改 2024-12-17 16:09:49 +08:00
xiaofajia
8c68f0b7c0 修改 2024-12-17 14:29:40 +08:00
xiaofajia
8f92fd463f 修改 2024-12-17 13:52:13 +08:00
xiaofajia
68512f2e92 修改 2024-12-17 13:04:26 +08:00
7 changed files with 136 additions and 15 deletions

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
import cn.iocoder.yudao.util.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
@ -122,4 +123,21 @@ public class InspectionFileController extends BaseController
}
return success(inspectionFileService.getCountByIds(ids));
}
/**
* 得到使用说明
*
* @author 小李
* @date 12:31 2024/12/17
**/
@GetMapping("/getPresent")
public CommonResult<?> getPresent(){
List<InspectionFile> files = inspectionFileService.list(new LambdaQueryWrapper<InspectionFile>().eq(InspectionFile::getFileName, "使用说明"));
if (CollUtil.isEmpty(files)){
return null;
}
InspectionFile inspectionFile = files.get(0);
return success(inspectionFile);
}
}

View File

@ -5,17 +5,23 @@ import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.InspectionRoleCommon;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.inspection.entity.InspectionEquInfo;
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
import cn.iocoder.yudao.module.inspection.service.IInspectionEquInfoService;
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -25,7 +31,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
*
* @author 小李
* @date 15:36 2024/12/15
**/
**/
@RestController
@RequestMapping("/admin-api/inspection/util")
public class InspectionUtilController {
@ -36,6 +42,12 @@ public class InspectionUtilController {
@Resource
private RoleApi roleApi;
@Resource
private IInspectionEquInfoService equInfoService;
@Resource
private IInspectionFileService fileService;
/**
* 根据用户取出当前用户的角色只针对检测
*
@ -43,10 +55,10 @@ public class InspectionUtilController {
* @date 15:15 2024/12/15
**/
@GetMapping("/getRoleName")
public CommonResult<?> getRoleName(){
public CommonResult<?> getRoleName() {
String name = "未知岗位";
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId());
if (CollUtil.isEmpty(roleIdsByUserId)){
if (CollUtil.isEmpty(roleIdsByUserId)) {
return success(name);
}
List<RoleReqDTO> roleList = roleApi.getRoleList();
@ -54,21 +66,74 @@ public class InspectionUtilController {
List<InspectionRoleCommon> roleCommons = Arrays.asList(InspectionRoleCommon.values());
List<String> codes = roleCommons.stream().map(InspectionRoleCommon::getCode).collect(Collectors.toList());
List<RoleReqDTO> inspectionRoles = roles.stream().filter(item -> codes.contains(item.getCode())).collect(Collectors.toList());
if (CollUtil.isEmpty(inspectionRoles)){
if (CollUtil.isEmpty(inspectionRoles)) {
return success(name);
}
Integer index = Integer.MAX_VALUE;
Integer index = Integer.MAX_VALUE;
for (RoleReqDTO inspectionRole : inspectionRoles) {
InspectionRoleCommon inspectionRoleCommon = InspectionRoleCommon.valueOf(inspectionRole.getCode().toUpperCase());
if (ObjectUtil.isEmpty(inspectionRoleCommon)){
if (ObjectUtil.isEmpty(inspectionRoleCommon)) {
continue;
}
Integer weight = inspectionRoleCommon.getWeight();
if (weight < index){
if (weight < index) {
index = weight;
name = inspectionRole.getName();
}
}
return success(name);
}
@GetMapping("/getTypeCount")
public CommonResult<?> getTypeCount(@RequestParam("partnerId") Long partnerId) {
Map<String, Long> map = new HashMap<>();
Long staffCount = roleApi.selectListByRoleId();
map.put("staff", staffCount);
Page<InspectionEquInfo> page = new Page<>(1, 1000);
IPage<InspectionEquInfo> equs = equInfoService.selectInspectionEquInfoList(page, new InspectionEquInfo());
map.put("equ", equs.getTotal());
long fileCount = fileService.count(new LambdaQueryWrapper<InspectionFile>().eq(InspectionFile::getType, "2"));
map.put("file", fileCount);
return success(map);
}
@GetMapping("/getRoleNameByIds")
public CommonResult<?> getRoleNameByIds(@RequestParam("ids") List<Long> ids) {
Map<Long, List<Long>> idToRoleIds = ids.stream().collect(Collectors.toMap(id -> id, id -> permissionApi.getRoleIdsByUserId(id)));
if (CollUtil.isEmpty(idToRoleIds)){
return null;
}
List<RoleReqDTO> roleList = roleApi.getRoleList();
List<InspectionRoleCommon> roleCommons = Arrays.asList(InspectionRoleCommon.values());
List<String> codes = roleCommons.stream().map(InspectionRoleCommon::getCode).collect(Collectors.toList());
return success(idToRoleIds.entrySet().stream().collect(Collectors.toMap(
Map.Entry::getKey,
item -> {
String name = "未知岗位";
if (CollUtil.isEmpty(item.getValue())){
return name;
}
List<RoleReqDTO> roles = roleList.stream().filter(i -> item.getValue().contains(i.getId())).collect(Collectors.toList());
if (CollUtil.isEmpty(roles)) {
return name;
}
List<RoleReqDTO> inspectionRoles = roles.stream().filter(i -> codes.contains(i.getCode())).collect(Collectors.toList());
if (CollUtil.isEmpty(inspectionRoles)){
return name;
}
Integer index = Integer.MAX_VALUE;
for (RoleReqDTO inspectionRole : inspectionRoles) {
InspectionRoleCommon inspectionRoleCommon = InspectionRoleCommon.valueOf(inspectionRole.getCode().toUpperCase());
if (ObjectUtil.isEmpty(inspectionRoleCommon)) {
continue;
}
Integer weight = inspectionRoleCommon.getWeight();
if (weight < index) {
index = weight;
name = inspectionRole.getName();
}
}
return name;
})));
}
}

View File

@ -62,4 +62,7 @@ public class InspectionEquInfo extends TenantBaseDO
@TableField(exist = false)
private Map<String,Object> params;
/** 设备类别(字典ins_equ_type) */
private String type;
}

View File

@ -597,7 +597,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
wrapper.eq(InspectionWorkNode::getStatus, status);
}
InspectionInfo inspectionInfo = baseMapper.selectById(id);
if (!inspectionInfo.getLeadManId().equals(userId)) {
if (ObjectUtil.isEmpty(inspectionInfo.getLeadManId()) || !inspectionInfo.getLeadManId().equals(userId)) {
wrapper.in(InspectionWorkNode::getRoleId, roleIds);
}
List<InspectionWorkNode> workNodes = workNodeService.list(wrapper);

View File

@ -8,13 +8,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectInspectionEquInfoList" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionEquInfo" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionEquInfo">
select * from inspection_equ_info
select * from inspection_equ_info
<where>
<if test="inspectionEquInfo.equName != null and inspectionEquInfo.equName != ''"> and equ_name like concat('%', #{inspectionEquInfo.equName}, '%')</if>
<if test="inspectionEquInfo.equModel != null and inspectionEquInfo.equModel != ''"> and equ_model like concat('%', #{inspectionEquInfo.equModel}, '%')</if>
<if test="inspectionEquInfo.equNumber != null and inspectionEquInfo.equNumber != ''"> and equ_number like concat('%', #{inspectionEquInfo.equNumber}, '%')</if>
<if test="inspectionEquInfo.equName != null and inspectionEquInfo.equName != ''">and equ_name like
concat('%', #{inspectionEquInfo.equName}, '%')
</if>
<if test="inspectionEquInfo.equModel != null and inspectionEquInfo.equModel != ''">and equ_model like
concat('%', #{inspectionEquInfo.equModel}, '%')
</if>
<if test="inspectionEquInfo.equNumber != null and inspectionEquInfo.equNumber != ''">and equ_number like
concat('%', #{inspectionEquInfo.equNumber}, '%')
</if>
<if test="inspectionEquInfo.params.beginNextCheckTime != null and inspectionEquInfo.params.beginNextCheckTime != '' and params.endNextCheckTime != null and params.endNextCheckTime != ''">
and next_check_time between #{inspectionEquInfo.params.beginNextCheckTime} and #{inspectionEquInfo.params.endNextCheckTime}</if>
and next_check_time between #{inspectionEquInfo.params.beginNextCheckTime} and
#{inspectionEquInfo.params.endNextCheckTime}
</if>
<if test="inspectionEquInfo.type != null and inspectionEquInfo.type != ''">
and `type` = #{inspectionEquInfo.type}
</if>
</where>
</select>

View File

@ -40,4 +40,11 @@ public interface RoleApi {
**/
List<UserDTO> selectUserListByRoleCode(Long tenantId,String code);
/**
* 通过角色id查询角色
*
* @author 小李
* @date 13:21 2024/12/17
**/
Long selectListByRoleId();
}

View File

@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.system.api.permission;
import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -64,4 +66,19 @@ public class RoleApiImpl implements RoleApi {
public List<UserDTO> selectUserListByRoleCode(Long tenantId,String code) {
return roleService.selectByRoleCode(tenantId,code);
}
/**
* 通过角色id查询角色
*
* @author 小李
* @date 13:21 2024/12/17
**/
@Override
public Long selectListByRoleId(){
RolePageReqVO rolePageReqVO = new RolePageReqVO();
rolePageReqVO.setPageNo(1);
rolePageReqVO.setPageSize(1000);
IPage<UserDTO> userDTOIPage = roleService.selectListByRoleId(rolePageReqVO);
return userDTOIPage.getTotal();
}
}