检测文件更新
This commit is contained in:
parent
dc4fcb297f
commit
ea24de5765
@ -2,10 +2,12 @@ package cn.iocoder.yudao.module.inspection.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
import cn.iocoder.yudao.module.core.controller.BaseController;
|
import cn.iocoder.yudao.module.core.controller.BaseController;
|
||||||
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
|
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
|
||||||
import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
|
import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
|
||||||
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
|
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
|
||||||
|
import cn.iocoder.yudao.module.inspection.vo.AssignAuthorityVo;
|
||||||
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
|
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
|
||||||
import cn.iocoder.yudao.util.ExcelUtil;
|
import cn.iocoder.yudao.util.ExcelUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@ -25,8 +27,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin-api/inspectionFile/inspectionFile")
|
@RequestMapping("/admin-api/inspectionFile/inspectionFile")
|
||||||
public class InspectionFileController extends BaseController
|
public class InspectionFileController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IInspectionFileService inspectionFileService;
|
private IInspectionFileService inspectionFileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -56,8 +57,7 @@ public class InspectionFileController extends BaseController
|
|||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, InspectionFile inspectionFile,
|
public void export(HttpServletResponse response, InspectionFile inspectionFile,
|
||||||
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
|
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
|
||||||
@RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize)
|
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
|
||||||
{
|
|
||||||
Page<InspectionFile> page = new Page<>(pageNum, pageSize);
|
Page<InspectionFile> page = new Page<>(pageNum, pageSize);
|
||||||
IPage<InspectionFile> list = inspectionFileService.selectInspectionFileList(page, inspectionFile);
|
IPage<InspectionFile> list = inspectionFileService.selectInspectionFileList(page, inspectionFile);
|
||||||
ExcelUtil<InspectionFile> util = new ExcelUtil<InspectionFile>(InspectionFile.class);
|
ExcelUtil<InspectionFile> util = new ExcelUtil<InspectionFile>(InspectionFile.class);
|
||||||
@ -68,8 +68,7 @@ public class InspectionFileController extends BaseController
|
|||||||
* 获取inspectionFile详细信息
|
* 获取inspectionFile详细信息
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public CommonResult getInfo(@PathVariable("id") Long id)
|
public CommonResult getInfo(@PathVariable("id") Long id) {
|
||||||
{
|
|
||||||
return success(inspectionFileService.selectInspectionFileById(id));
|
return success(inspectionFileService.selectInspectionFileById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,9 +111,9 @@ public class InspectionFileController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 根据id统计数量
|
* 根据id统计数量
|
||||||
*
|
*
|
||||||
|
* @param ids ids
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 14:30 2024/12/14
|
* @date 14:30 2024/12/14
|
||||||
* @param ids ids
|
|
||||||
**/
|
**/
|
||||||
@GetMapping("/getCountByIds")
|
@GetMapping("/getCountByIds")
|
||||||
public CommonResult<?> getCountByIds(@RequestParam(value = "ids", required = false) List<Long> ids) {
|
public CommonResult<?> getCountByIds(@RequestParam(value = "ids", required = false) List<Long> ids) {
|
||||||
@ -140,4 +139,29 @@ public class InspectionFileController extends BaseController
|
|||||||
return success(inspectionFile);
|
return success(inspectionFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配权限
|
||||||
|
*
|
||||||
|
* @param assignAuthorityVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/assignAuthority")
|
||||||
|
public CommonResult assignAuthority(@RequestBody AssignAuthorityVo assignAuthorityVo) {
|
||||||
|
if (CollUtil.isEmpty(assignAuthorityVo.getUserIds())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return success(inspectionFileService.assignAuthority(assignAuthorityVo.getUserIds(), assignAuthorityVo.getFileId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据文件id获取有权限的用户id
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getUserIdsByFileId")
|
||||||
|
public CommonResult getUserIdsByFileId(Integer fileId) {
|
||||||
|
List<Long> userIds = inspectionFileService.getUserIdsByFileId(fileId);
|
||||||
|
return success(userIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.inspection.entity;
|
package cn.iocoder.yudao.module.inspection.entity;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@ -10,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.iocoder.yudao.annotation.Excel;
|
import cn.iocoder.yudao.annotation.Excel;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||||
|
import org.apache.commons.compress.harmony.pack200.NewAttributeBands;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* equInfo对象 inspection_equ_info
|
* equInfo对象 inspection_equ_info
|
||||||
@ -65,4 +68,15 @@ public class InspectionEquInfo extends TenantBaseDO
|
|||||||
/** 设备类别(字典:ins_equ_type) */
|
/** 设备类别(字典:ins_equ_type) */
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件夹id
|
||||||
|
*/
|
||||||
|
private Long folderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件集合
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<FileDO> fileList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package cn.iocoder.yudao.module.inspection.entity;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 资料权限
|
||||||
|
* @Author: 86187
|
||||||
|
* @Date: 2025/02/06 15:30
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class InspectionFileUser {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
private Integer fileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多租户编号
|
||||||
|
*/
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
/**
|
||||||
|
* 创建者,目前使用 SysUser 的 id 编号
|
||||||
|
*
|
||||||
|
* 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.VARCHAR)
|
||||||
|
private String creator;
|
||||||
|
/**
|
||||||
|
* 更新者,目前使用 SysUser 的 id 编号
|
||||||
|
*
|
||||||
|
* 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.VARCHAR)
|
||||||
|
private String updater;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package cn.iocoder.yudao.module.inspection.mapper;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.inspection.entity.InspectionFileUser;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 资料权限
|
||||||
|
* @Author: 86187
|
||||||
|
* @Date: 2025/02/06 15:35
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface InspectionFileUserMapper extends BaseMapper<InspectionFileUser> {
|
||||||
|
}
|
@ -14,8 +14,7 @@ import java.util.Map;
|
|||||||
* @author zcy
|
* @author zcy
|
||||||
* @date 2023-10-13
|
* @date 2023-10-13
|
||||||
*/
|
*/
|
||||||
public interface IInspectionFileService extends IService<InspectionFile>
|
public interface IInspectionFileService extends IService<InspectionFile> {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询inspectionFile
|
* 查询inspectionFile
|
||||||
*
|
*
|
||||||
@ -32,6 +31,7 @@ public interface IInspectionFileService extends IService<InspectionFile>
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public InspectionFile insertInspectionFile(InspectionFile inspectionFile);
|
public InspectionFile insertInspectionFile(InspectionFile inspectionFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增inspectionFile
|
* 新增inspectionFile
|
||||||
*
|
*
|
||||||
@ -77,9 +77,26 @@ public interface IInspectionFileService extends IService<InspectionFile>
|
|||||||
/**
|
/**
|
||||||
* 根据id统计数量
|
* 根据id统计数量
|
||||||
*
|
*
|
||||||
|
* @param ids ids
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 14:30 2024/12/14
|
* @date 14:30 2024/12/14
|
||||||
* @param ids ids
|
|
||||||
**/
|
**/
|
||||||
Map<Long, Long> getCountByIds(List<Long> ids);
|
Map<Long, Long> getCountByIds(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配权限
|
||||||
|
*
|
||||||
|
* @param userIds 用户id集合
|
||||||
|
* @param fileId 文件id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Object assignAuthority(List<Long> userIds, Integer fileId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据文件id获取有权限的用户id集合
|
||||||
|
*
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Long> getUserIdsByFileId(Integer fileId);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package cn.iocoder.yudao.module.inspection.service;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.inspection.entity.InspectionFileUser;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 资料权限
|
||||||
|
* @Author: 86187
|
||||||
|
* @Date: 2025/02/06 15:33
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface InspectionFileUserService extends IService<InspectionFileUser> {
|
||||||
|
}
|
@ -1,16 +1,19 @@
|
|||||||
package cn.iocoder.yudao.module.inspection.service.impl;
|
package cn.iocoder.yudao.module.inspection.service.impl;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.module.constant.InspectionConstants;
|
||||||
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||||
|
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
|
||||||
|
import cn.iocoder.yudao.module.inspection.entity.InspectionStaff;
|
||||||
|
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import cn.iocoder.yudao.util.DateUtils;
|
import cn.iocoder.yudao.util.DateUtils;
|
||||||
@ -30,12 +33,14 @@ import cn.iocoder.yudao.module.inspection.service.IInspectionEquInfoService;
|
|||||||
* @date 2023-10-13
|
* @date 2023-10-13
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoMapper,InspectionEquInfo> implements IInspectionEquInfoService
|
public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoMapper, InspectionEquInfo> implements IInspectionEquInfoService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IWarnMessageService messageService;
|
private IWarnMessageService messageService;
|
||||||
private CollectorRegistry collectorRegistry;
|
private CollectorRegistry collectorRegistry;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IInspectionFileService inspectionFileService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询equInfo
|
* 查询equInfo
|
||||||
*
|
*
|
||||||
@ -43,9 +48,25 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
* @return equInfo
|
* @return equInfo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public InspectionEquInfo selectInspectionEquInfoById(Long id)
|
public InspectionEquInfo selectInspectionEquInfoById(Long id) {
|
||||||
{
|
InspectionEquInfo inspectionEquInfo = baseMapper.selectInspectionEquInfoById(id);
|
||||||
return baseMapper.selectInspectionEquInfoById(id);
|
|
||||||
|
//查询文件附件
|
||||||
|
if (ObjectUtil.isNotEmpty(inspectionEquInfo.getFolderId())) {
|
||||||
|
List<InspectionFile> fileList = inspectionFileService.list(Wrappers.<InspectionFile>lambdaQuery()
|
||||||
|
.eq(InspectionFile::getFatherId, inspectionEquInfo.getFolderId()));
|
||||||
|
|
||||||
|
List<FileDO> copyFileList = new ArrayList<>();
|
||||||
|
for (InspectionFile inspectionFile : fileList) {
|
||||||
|
FileDO fileDO = new FileDO();
|
||||||
|
//把文件名后缀截取掉
|
||||||
|
fileDO.setUrl(inspectionFile.getFilePath());
|
||||||
|
fileDO.setName(inspectionFile.getFileName());
|
||||||
|
copyFileList.add(fileDO);
|
||||||
|
}
|
||||||
|
inspectionEquInfo.setFileList(copyFileList);
|
||||||
|
}
|
||||||
|
return inspectionEquInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,8 +76,7 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
* @return equInfo
|
* @return equInfo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage<InspectionEquInfo> selectInspectionEquInfoList(Page page,InspectionEquInfo inspectionEquInfo)
|
public IPage<InspectionEquInfo> selectInspectionEquInfoList(Page page, InspectionEquInfo inspectionEquInfo) {
|
||||||
{
|
|
||||||
return baseMapper.selectInspectionEquInfoList(page, inspectionEquInfo);
|
return baseMapper.selectInspectionEquInfoList(page, inspectionEquInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +87,7 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertInspectionEquInfo(InspectionEquInfo inspectionEquInfo)
|
public int insertInspectionEquInfo(InspectionEquInfo inspectionEquInfo) {
|
||||||
{
|
|
||||||
int insert = baseMapper.insert(inspectionEquInfo);
|
int insert = baseMapper.insert(inspectionEquInfo);
|
||||||
if (ObjectUtil.isNotEmpty(inspectionEquInfo.getNextCheckTime())) {
|
if (ObjectUtil.isNotEmpty(inspectionEquInfo.getNextCheckTime())) {
|
||||||
//同时处理提醒信息
|
//同时处理提醒信息
|
||||||
@ -87,6 +106,10 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
warnMessage.setWarnTime(newDate);
|
warnMessage.setWarnTime(newDate);
|
||||||
messageService.save(warnMessage);
|
messageService.save(warnMessage);
|
||||||
}
|
}
|
||||||
|
//文件处理
|
||||||
|
if (CollUtil.isNotEmpty(inspectionEquInfo.getFileList())) {
|
||||||
|
addFile(inspectionEquInfo.getFileList(), inspectionEquInfo.getEquName(), null, inspectionEquInfo.getId());
|
||||||
|
}
|
||||||
return insert;
|
return insert;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,8 +121,7 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DSTransactional
|
@DSTransactional
|
||||||
public int updateInspectionEquInfo(InspectionEquInfo inspectionEquInfo)
|
public int updateInspectionEquInfo(InspectionEquInfo inspectionEquInfo) {
|
||||||
{
|
|
||||||
LambdaQueryWrapper<WarnMessage> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WarnMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(WarnMessage::getType, "equ").eq(WarnMessage::getObjectId, inspectionEquInfo.getId());
|
queryWrapper.eq(WarnMessage::getType, "equ").eq(WarnMessage::getObjectId, inspectionEquInfo.getId());
|
||||||
List<WarnMessage> list = messageService.list(queryWrapper);
|
List<WarnMessage> list = messageService.list(queryWrapper);
|
||||||
@ -125,6 +147,10 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
warnMessage.setWarnTime(newDate);
|
warnMessage.setWarnTime(newDate);
|
||||||
messageService.save(warnMessage);
|
messageService.save(warnMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(inspectionEquInfo.getFileList())) {
|
||||||
|
addFile(inspectionEquInfo.getFileList(), inspectionEquInfo.getEquName(), inspectionEquInfo.getFolderId(), inspectionEquInfo.getId());
|
||||||
|
}
|
||||||
return baseMapper.updateById(inspectionEquInfo);
|
return baseMapper.updateById(inspectionEquInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +161,7 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteInspectionEquInfoByIds(Long[] ids)
|
public int deleteInspectionEquInfoByIds(Long[] ids) {
|
||||||
{
|
|
||||||
return baseMapper.deleteBatchIds(Arrays.asList(ids));
|
return baseMapper.deleteBatchIds(Arrays.asList(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,8 +172,7 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteInspectionEquInfoById(Long id)
|
public int deleteInspectionEquInfoById(Long id) {
|
||||||
{
|
|
||||||
LambdaQueryWrapper<WarnMessage> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WarnMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(WarnMessage::getType, "file").eq(WarnMessage::getObjectId, id);
|
queryWrapper.eq(WarnMessage::getType, "file").eq(WarnMessage::getObjectId, id);
|
||||||
WarnMessage one = messageService.getOne(queryWrapper);
|
WarnMessage one = messageService.getOne(queryWrapper);
|
||||||
@ -158,4 +182,66 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
|||||||
}
|
}
|
||||||
return baseMapper.deleteById(id);
|
return baseMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加设备附件
|
||||||
|
*
|
||||||
|
* @param fileList 文件集合
|
||||||
|
* @param equName 设备
|
||||||
|
* @param fatherId 父级文件夹id
|
||||||
|
*/
|
||||||
|
public void addFile(List<FileDO> fileList, String equName, Long fatherId, Long eqId) {
|
||||||
|
if (ObjectUtil.isEmpty(fatherId)) {
|
||||||
|
//添加文件夹
|
||||||
|
InspectionFile inspectionFile = new InspectionFile();
|
||||||
|
inspectionFile.setFileName(equName + InspectionConstants.INSPECTION_FOLDER_SUFFIX);
|
||||||
|
inspectionFile.setType(InspectionConstants.INSPECTION_FOLDER);
|
||||||
|
|
||||||
|
fatherId = inspectionFileService.insertInspectionFile(inspectionFile).getId();
|
||||||
|
|
||||||
|
//更新设备表中的文件夹id
|
||||||
|
this.update(Wrappers.<InspectionEquInfo>lambdaUpdate()
|
||||||
|
.eq(InspectionEquInfo::getId, eqId)
|
||||||
|
.set(InspectionEquInfo::getFolderId, fatherId));
|
||||||
|
} else {
|
||||||
|
//删除文件下的所有文件
|
||||||
|
inspectionFileService.remove(Wrappers.<InspectionFile>lambdaQuery()
|
||||||
|
.eq(InspectionFile::getFatherId, fatherId)
|
||||||
|
.eq(InspectionFile::getType, InspectionConstants.INSPECTION_FILE)
|
||||||
|
.eq(InspectionFile::getIsStaffFile, InspectionConstants.INSPECTION_IS_STAFF_FILE));
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加文件
|
||||||
|
List<InspectionFile> fileDOList = new ArrayList<>();
|
||||||
|
for (FileDO fileDO : fileList) {
|
||||||
|
InspectionFile file = new InspectionFile();
|
||||||
|
file.setFileName(removeFileExtension(fileDO.getName()));
|
||||||
|
file.setFilePath(fileDO.getUrl());
|
||||||
|
file.setType(InspectionConstants.INSPECTION_FILE);
|
||||||
|
file.setFatherId(fatherId);
|
||||||
|
file.setIsStaffFile(InspectionConstants.INSPECTION_IS_STAFF_FILE);
|
||||||
|
|
||||||
|
fileDOList.add(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量插入文件
|
||||||
|
inspectionFileService.insertBatchInspectionFile(fileDOList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去除文件名中的后缀
|
||||||
|
*
|
||||||
|
* @param filename
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String removeFileExtension(String filename) {
|
||||||
|
if (filename == null) {
|
||||||
|
return null; // 或者你可以选择返回一个空字符串,取决于你的业务需求
|
||||||
|
}
|
||||||
|
int lastDotIndex = filename.lastIndexOf('.');
|
||||||
|
if (lastDotIndex == -1) {
|
||||||
|
return filename; // 如果没有找到点,则返回原文件名
|
||||||
|
}
|
||||||
|
return filename.substring(0, lastDotIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.inspection.service.impl;
|
package cn.iocoder.yudao.module.inspection.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
|
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
|
||||||
|
import cn.iocoder.yudao.module.inspection.entity.InspectionFileUser;
|
||||||
import cn.iocoder.yudao.module.inspection.entity.WarnMessage;
|
import cn.iocoder.yudao.module.inspection.entity.WarnMessage;
|
||||||
import cn.iocoder.yudao.module.inspection.mapper.InspectionFileMapper;
|
import cn.iocoder.yudao.module.inspection.mapper.InspectionFileMapper;
|
||||||
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
|
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
|
||||||
import cn.iocoder.yudao.module.inspection.service.IWarnMessageService;
|
import cn.iocoder.yudao.module.inspection.service.IWarnMessageService;
|
||||||
|
import cn.iocoder.yudao.module.inspection.service.InspectionFileUserService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -13,6 +16,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -29,6 +33,9 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IWarnMessageService messageService;
|
private IWarnMessageService messageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InspectionFileUserService inspectionFileUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询inspectionFile
|
* 查询inspectionFile
|
||||||
*
|
*
|
||||||
@ -218,4 +225,52 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
Collectors.counting()
|
Collectors.counting()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配权限
|
||||||
|
*
|
||||||
|
* @param userIds 用户id集合
|
||||||
|
* @param fileId 文件id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object assignAuthority(List<Long> userIds, Integer fileId) {
|
||||||
|
//查询对应文件
|
||||||
|
InspectionFile inspectionFile = this.getById(fileId);
|
||||||
|
if (ObjectUtil.isNotEmpty(inspectionFile)) {
|
||||||
|
//获取文件的id与所有父级
|
||||||
|
String fileCode = inspectionFile.getFileCode();
|
||||||
|
//根据逗号分割fileCode
|
||||||
|
String[] code = fileCode.split(",");
|
||||||
|
List<InspectionFileUser> inspectionFileUsers = new ArrayList<>();
|
||||||
|
for (Long userId : userIds) {
|
||||||
|
for (String s : code) {
|
||||||
|
InspectionFileUser inspectionFileUser = new InspectionFileUser();
|
||||||
|
inspectionFileUser.setUserId(userId);
|
||||||
|
inspectionFileUser.setFileId(Integer.parseInt(s));
|
||||||
|
inspectionFileUsers.add(inspectionFileUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//删除之前的权限
|
||||||
|
inspectionFileUserService.remove(new LambdaQueryWrapper<InspectionFileUser>().in(InspectionFileUser::getFileId, code));
|
||||||
|
//批量保存
|
||||||
|
inspectionFileUserService.saveBatch(inspectionFileUsers);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据文件id获取有权限的用户id集合
|
||||||
|
*
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Long> getUserIdsByFileId(Integer fileId) {
|
||||||
|
List<InspectionFileUser> inspectionFileUsers = inspectionFileUserService.list(new LambdaQueryWrapper<InspectionFileUser>().eq(InspectionFileUser::getFileId, fileId));
|
||||||
|
if (ObjectUtil.isNotEmpty(inspectionFileUsers)) {
|
||||||
|
return inspectionFileUsers.stream().map(InspectionFileUser::getUserId).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package cn.iocoder.yudao.module.inspection.service.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.inspection.entity.InspectionFileUser;
|
||||||
|
import cn.iocoder.yudao.module.inspection.mapper.InspectionFileUserMapper;
|
||||||
|
import cn.iocoder.yudao.module.inspection.service.InspectionFileUserService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 资料权限
|
||||||
|
* @Author: 86187
|
||||||
|
* @Date: 2025/02/06 15:33
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class InspectionFileUserServiceImpl extends ServiceImpl<InspectionFileUserMapper, InspectionFileUser> implements InspectionFileUserService {
|
||||||
|
}
|
@ -174,6 +174,9 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
|
|||||||
inspectionStaff.setUserId(userId);
|
inspectionStaff.setUserId(userId);
|
||||||
//新增检测员工子表
|
//新增检测员工子表
|
||||||
this.save(inspectionStaff);
|
this.save(inspectionStaff);
|
||||||
|
if (ObjectUtil.isNotEmpty(inspectionStaffVo.getFileList())) {
|
||||||
|
addFile(inspectionStaffVo.getFileList(), inspectionStaffVo.getNickname(), null, inspectionStaff.getUserId());
|
||||||
|
}
|
||||||
return inspectionStaff.getUserId();
|
return inspectionStaff.getUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package cn.iocoder.yudao.module.inspection.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分配资料权限
|
||||||
|
* @Author: 86187
|
||||||
|
* @Date: 2025/02/06 16:31
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AssignAuthorityVo {
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
List<Long> userIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
Integer fileId;
|
||||||
|
}
|
@ -10,6 +10,7 @@ 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 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>
|
<where>
|
||||||
|
deleted = 0
|
||||||
<if test="inspectionEquInfo.equName != null and inspectionEquInfo.equName != ''">and equ_name like
|
<if test="inspectionEquInfo.equName != null and inspectionEquInfo.equName != ''">and equ_name like
|
||||||
concat('%', #{inspectionEquInfo.equName}, '%')
|
concat('%', #{inspectionEquInfo.equName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.inspection.mapper.InspectionFileUserMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user