检测文件更新
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.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.inspection.entity.InspectionFile;
|
||||
import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
|
||||
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.util.ExcelUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -25,8 +27,7 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/inspectionFile/inspectionFile")
|
||||
public class InspectionFileController extends BaseController
|
||||
{
|
||||
public class InspectionFileController extends BaseController {
|
||||
@Autowired
|
||||
private IInspectionFileService inspectionFileService;
|
||||
@Autowired
|
||||
@ -37,15 +38,15 @@ public class InspectionFileController extends BaseController
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public CommonResult list(InspectionFile inspectionFile,
|
||||
@RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) throws Exception {
|
||||
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) throws Exception {
|
||||
ShopMallPartners partners = partnerService.shopInfoByUserId();
|
||||
inspectionFile.setPartnerId(partners.getPartnerId());
|
||||
|
||||
Page<InspectionFile> page = new Page<>(pageNum, pageSize);
|
||||
|
||||
// 使用MyBatis-Plus的分页查询,将结果转换为Page对象
|
||||
IPage<InspectionFile> list = inspectionFileService.selectInspectionFileList(page,inspectionFile);
|
||||
IPage<InspectionFile> list = inspectionFileService.selectInspectionFileList(page, inspectionFile);
|
||||
|
||||
return success(list);
|
||||
}
|
||||
@ -55,11 +56,10 @@ public class InspectionFileController extends BaseController
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, InspectionFile inspectionFile,
|
||||
@RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer 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);
|
||||
util.exportExcel(response, list.getRecords(), "inspectionFile数据");
|
||||
}
|
||||
@ -68,8 +68,7 @@ public class InspectionFileController extends BaseController
|
||||
* 获取inspectionFile详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public CommonResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
public CommonResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(inspectionFileService.selectInspectionFileById(id));
|
||||
}
|
||||
|
||||
@ -90,7 +89,7 @@ public class InspectionFileController extends BaseController
|
||||
public CommonResult edit(@RequestBody InspectionFile inspectionFile) throws Exception {
|
||||
ShopMallPartners partners = partnerService.shopInfo();
|
||||
InspectionFile file = inspectionFileService.selectInspectionFileById(inspectionFile.getId());
|
||||
if (!partners.getPartnerId().equals(file.getPartnerId())){
|
||||
if (!partners.getPartnerId().equals(file.getPartnerId())) {
|
||||
return null;
|
||||
}
|
||||
return toAjax(inspectionFileService.updateInspectionFile(inspectionFile));
|
||||
@ -103,7 +102,7 @@ public class InspectionFileController extends BaseController
|
||||
public CommonResult remove(@PathVariable Long id) throws Exception {
|
||||
ShopMallPartners partners = partnerService.shopInfo();
|
||||
InspectionFile file = inspectionFileService.selectInspectionFileById(id);
|
||||
if (!partners.getPartnerId().equals(file.getPartnerId())){
|
||||
if (!partners.getPartnerId().equals(file.getPartnerId())) {
|
||||
return null;
|
||||
}
|
||||
return toAjax(inspectionFileService.deleteInspectionFileById(id));
|
||||
@ -112,13 +111,13 @@ public class InspectionFileController extends BaseController
|
||||
/**
|
||||
* 根据id统计数量
|
||||
*
|
||||
* @param ids ids
|
||||
* @author 小李
|
||||
* @date 14:30 2024/12/14
|
||||
* @param ids ids
|
||||
**/
|
||||
**/
|
||||
@GetMapping("/getCountByIds")
|
||||
public CommonResult<?> getCountByIds(@RequestParam(value = "ids" ,required = false) List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)){
|
||||
public CommonResult<?> getCountByIds(@RequestParam(value = "ids", required = false) List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
return success(inspectionFileService.getCountByIds(ids));
|
||||
@ -129,15 +128,40 @@ public class InspectionFileController extends BaseController
|
||||
*
|
||||
* @author 小李
|
||||
* @date 12:31 2024/12/17
|
||||
**/
|
||||
**/
|
||||
@GetMapping("/getPresent")
|
||||
public CommonResult<?> getPresent(){
|
||||
public CommonResult<?> getPresent() {
|
||||
List<InspectionFile> files = inspectionFileService.list(new LambdaQueryWrapper<InspectionFile>().eq(InspectionFile::getFileName, "使用说明"));
|
||||
if (CollUtil.isEmpty(files)){
|
||||
if (CollUtil.isEmpty(files)) {
|
||||
return null;
|
||||
}
|
||||
InspectionFile inspectionFile = files.get(0);
|
||||
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;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
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.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -10,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import cn.iocoder.yudao.annotation.Excel;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import org.apache.commons.compress.harmony.pack200.NewAttributeBands;
|
||||
|
||||
/**
|
||||
* equInfo对象 inspection_equ_info
|
||||
@ -65,4 +68,15 @@ public class InspectionEquInfo extends TenantBaseDO
|
||||
/** 设备类别(字典:ins_equ_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
|
||||
* @date 2023-10-13
|
||||
*/
|
||||
public interface IInspectionFileService extends IService<InspectionFile>
|
||||
{
|
||||
public interface IInspectionFileService extends IService<InspectionFile> {
|
||||
/**
|
||||
* 查询inspectionFile
|
||||
*
|
||||
@ -32,6 +31,7 @@ public interface IInspectionFileService extends IService<InspectionFile>
|
||||
* @return 结果
|
||||
*/
|
||||
public InspectionFile insertInspectionFile(InspectionFile inspectionFile);
|
||||
|
||||
/**
|
||||
* 新增inspectionFile
|
||||
*
|
||||
@ -68,7 +68,7 @@ public interface IInspectionFileService extends IService<InspectionFile>
|
||||
/**
|
||||
* 分页查询 InspectionFile 列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param page 分页对象
|
||||
* @param inspectionFile 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
@ -77,9 +77,26 @@ public interface IInspectionFileService extends IService<InspectionFile>
|
||||
/**
|
||||
* 根据id统计数量
|
||||
*
|
||||
* @param ids ids
|
||||
* @author 小李
|
||||
* @date 14:30 2024/12/14
|
||||
* @param ids 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;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.service.impl.ServiceImpl;
|
||||
import cn.iocoder.yudao.util.DateUtils;
|
||||
@ -30,12 +33,14 @@ import cn.iocoder.yudao.module.inspection.service.IInspectionEquInfoService;
|
||||
* @date 2023-10-13
|
||||
*/
|
||||
@Service
|
||||
public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoMapper,InspectionEquInfo> implements IInspectionEquInfoService
|
||||
{
|
||||
public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoMapper, InspectionEquInfo> implements IInspectionEquInfoService {
|
||||
@Autowired
|
||||
private IWarnMessageService messageService;
|
||||
private CollectorRegistry collectorRegistry;
|
||||
|
||||
@Autowired
|
||||
private IInspectionFileService inspectionFileService;
|
||||
|
||||
/**
|
||||
* 查询equInfo
|
||||
*
|
||||
@ -43,9 +48,25 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
* @return equInfo
|
||||
*/
|
||||
@Override
|
||||
public InspectionEquInfo selectInspectionEquInfoById(Long id)
|
||||
{
|
||||
return baseMapper.selectInspectionEquInfoById(id);
|
||||
public InspectionEquInfo selectInspectionEquInfoById(Long id) {
|
||||
InspectionEquInfo inspectionEquInfo = 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,9 +76,8 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
* @return equInfo
|
||||
*/
|
||||
@Override
|
||||
public IPage<InspectionEquInfo> selectInspectionEquInfoList(Page page,InspectionEquInfo inspectionEquInfo)
|
||||
{
|
||||
return baseMapper.selectInspectionEquInfoList(page,inspectionEquInfo);
|
||||
public IPage<InspectionEquInfo> selectInspectionEquInfoList(Page page, InspectionEquInfo inspectionEquInfo) {
|
||||
return baseMapper.selectInspectionEquInfoList(page, inspectionEquInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,14 +87,13 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertInspectionEquInfo(InspectionEquInfo inspectionEquInfo)
|
||||
{
|
||||
public int insertInspectionEquInfo(InspectionEquInfo inspectionEquInfo) {
|
||||
int insert = baseMapper.insert(inspectionEquInfo);
|
||||
if (ObjectUtil.isNotEmpty(inspectionEquInfo.getNextCheckTime())){
|
||||
if (ObjectUtil.isNotEmpty(inspectionEquInfo.getNextCheckTime())) {
|
||||
//同时处理提醒信息
|
||||
WarnMessage warnMessage =new WarnMessage();
|
||||
WarnMessage warnMessage = new WarnMessage();
|
||||
warnMessage.setTitle("设备检测即将到期");
|
||||
warnMessage.setContent("名为:"+inspectionEquInfo.getEquName()+"的设备即将到设定的检测时间,请及时处理相关事项!");
|
||||
warnMessage.setContent("名为:" + inspectionEquInfo.getEquName() + "的设备即将到设定的检测时间,请及时处理相关事项!");
|
||||
warnMessage.setIsRead("0");
|
||||
warnMessage.setPartnerId(inspectionEquInfo.getPartnerId());
|
||||
warnMessage.setType("equ");
|
||||
@ -87,6 +106,10 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
warnMessage.setWarnTime(newDate);
|
||||
messageService.save(warnMessage);
|
||||
}
|
||||
//文件处理
|
||||
if (CollUtil.isNotEmpty(inspectionEquInfo.getFileList())) {
|
||||
addFile(inspectionEquInfo.getFileList(), inspectionEquInfo.getEquName(), null, inspectionEquInfo.getId());
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
|
||||
@ -98,21 +121,20 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
*/
|
||||
@Override
|
||||
@DSTransactional
|
||||
public int updateInspectionEquInfo(InspectionEquInfo inspectionEquInfo)
|
||||
{
|
||||
LambdaQueryWrapper<WarnMessage> queryWrapper =new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WarnMessage::getType,"equ").eq(WarnMessage::getObjectId,inspectionEquInfo.getId());
|
||||
public int updateInspectionEquInfo(InspectionEquInfo inspectionEquInfo) {
|
||||
LambdaQueryWrapper<WarnMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WarnMessage::getType, "equ").eq(WarnMessage::getObjectId, inspectionEquInfo.getId());
|
||||
List<WarnMessage> list = messageService.list(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
//更新处理
|
||||
List<Long> ids = list.stream().map(WarnMessage::getId).collect(Collectors.toList());
|
||||
messageService.removeBatchByIds(ids);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(inspectionEquInfo.getNextCheckTime())){
|
||||
if (ObjectUtil.isNotEmpty(inspectionEquInfo.getNextCheckTime())) {
|
||||
//同时处理提醒信息
|
||||
WarnMessage warnMessage =new WarnMessage();
|
||||
WarnMessage warnMessage = new WarnMessage();
|
||||
warnMessage.setTitle("设备检测即将到期");
|
||||
warnMessage.setContent("名为:"+inspectionEquInfo.getEquName()+"的设备即将到设定的检测时间,请及时处理相关事项!");
|
||||
warnMessage.setContent("名为:" + inspectionEquInfo.getEquName() + "的设备即将到设定的检测时间,请及时处理相关事项!");
|
||||
warnMessage.setIsRead("0");
|
||||
warnMessage.setPartnerId(inspectionEquInfo.getPartnerId());
|
||||
warnMessage.setType("equ");
|
||||
@ -125,6 +147,10 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
warnMessage.setWarnTime(newDate);
|
||||
messageService.save(warnMessage);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(inspectionEquInfo.getFileList())) {
|
||||
addFile(inspectionEquInfo.getFileList(), inspectionEquInfo.getEquName(), inspectionEquInfo.getFolderId(), inspectionEquInfo.getId());
|
||||
}
|
||||
return baseMapper.updateById(inspectionEquInfo);
|
||||
}
|
||||
|
||||
@ -135,8 +161,7 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteInspectionEquInfoByIds(Long[] ids)
|
||||
{
|
||||
public int deleteInspectionEquInfoByIds(Long[] ids) {
|
||||
return baseMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@ -147,15 +172,76 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteInspectionEquInfoById(Long id)
|
||||
{
|
||||
LambdaQueryWrapper<WarnMessage> queryWrapper =new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WarnMessage::getType,"file").eq(WarnMessage::getObjectId,id);
|
||||
public int deleteInspectionEquInfoById(Long id) {
|
||||
LambdaQueryWrapper<WarnMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WarnMessage::getType, "file").eq(WarnMessage::getObjectId, id);
|
||||
WarnMessage one = messageService.getOne(queryWrapper);
|
||||
if (ObjectUtil.isNotEmpty(one)){
|
||||
if (ObjectUtil.isNotEmpty(one)) {
|
||||
//更新处理
|
||||
messageService.removeById(one.getId());
|
||||
}
|
||||
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;
|
||||
|
||||
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.InspectionFileUser;
|
||||
import cn.iocoder.yudao.module.inspection.entity.WarnMessage;
|
||||
import cn.iocoder.yudao.module.inspection.mapper.InspectionFileMapper;
|
||||
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
|
||||
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.metadata.IPage;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -29,6 +33,9 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
||||
@Autowired
|
||||
private IWarnMessageService messageService;
|
||||
|
||||
@Autowired
|
||||
private InspectionFileUserService inspectionFileUserService;
|
||||
|
||||
/**
|
||||
* 查询inspectionFile
|
||||
*
|
||||
@ -218,4 +225,52 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
||||
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);
|
||||
//新增检测员工子表
|
||||
this.save(inspectionStaff);
|
||||
if (ObjectUtil.isNotEmpty(inspectionStaffVo.getFileList())) {
|
||||
addFile(inspectionStaffVo.getFileList(), inspectionStaffVo.getNickname(), null, 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 * from inspection_equ_info
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="inspectionEquInfo.equName != null and inspectionEquInfo.equName != ''">and equ_name like
|
||||
concat('%', #{inspectionEquInfo.equName}, '%')
|
||||
</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