检测员工新增附件与inspection_file表联动
This commit is contained in:
parent
07b9e5b562
commit
1e6d1a68c2
@ -12,4 +12,24 @@ public class InspectionConstants {
|
|||||||
* 检测基础员工角色 Code
|
* 检测基础员工角色 Code
|
||||||
*/
|
*/
|
||||||
public static final String INSPECTION_BASE_STAFF_ROLE = "jcworker";
|
public static final String INSPECTION_BASE_STAFF_ROLE = "jcworker";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件类型:文件加
|
||||||
|
*/
|
||||||
|
public static final String INSPECTION_FOLDER = "1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件夹后缀 (新增检测员工时,上传附件新建文件夹)
|
||||||
|
*/
|
||||||
|
public static final String INSPECTION_FOLDER_SUFFIX = "的文件夹";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件类型:文件
|
||||||
|
*/
|
||||||
|
public static final String INSPECTION_FILE = "2";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是员工附件
|
||||||
|
*/
|
||||||
|
public static final Integer INSPECTION_IS_STAFF_FILE = 0;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class InspectionFileController extends BaseController
|
|||||||
public CommonResult add(@RequestBody InspectionFile inspectionFile) throws Exception {
|
public CommonResult add(@RequestBody InspectionFile inspectionFile) throws Exception {
|
||||||
ShopMallPartners partners = partnerService.shopInfo();
|
ShopMallPartners partners = partnerService.shopInfo();
|
||||||
inspectionFile.setPartnerId(partners.getPartnerId());
|
inspectionFile.setPartnerId(partners.getPartnerId());
|
||||||
return toAjax(inspectionFileService.insertInspectionFile(inspectionFile));
|
return success(inspectionFileService.insertInspectionFile(inspectionFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.PhoneUtil;
|
import cn.hutool.core.util.PhoneUtil;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.core.controller.BaseController;
|
import cn.iocoder.yudao.module.core.controller.BaseController;
|
||||||
import cn.iocoder.yudao.module.inspection.enums.DriverLicenseType;
|
import cn.iocoder.yudao.module.inspection.enums.DriverLicenseType;
|
||||||
@ -17,17 +16,9 @@ import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery;
|
|||||||
import cn.iocoder.yudao.module.inspection.service.InspectionStaffService;
|
import cn.iocoder.yudao.module.inspection.service.InspectionStaffService;
|
||||||
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffExportVo;
|
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffExportVo;
|
||||||
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffSaveVo;
|
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffSaveVo;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
||||||
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;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -37,7 +28,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
||||||
import static cn.iocoder.yudao.framework.excel.core.util.ExcelUtils.exportBlankTemplate;
|
import static cn.iocoder.yudao.framework.excel.core.util.ExcelUtils.exportBlankTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +50,12 @@ public class InspectionFile extends TenantBaseDO
|
|||||||
@Excel(name = "提醒时间", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "提醒时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date warnTime;
|
private Date warnTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为员工附 0-是 1-否
|
||||||
|
*/
|
||||||
|
@TableField("is_staff_file")
|
||||||
|
private Integer isStaffFile;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Map<String,Object> params;
|
private Map<String,Object> params;
|
||||||
}
|
}
|
||||||
|
@ -93,4 +93,10 @@ public class InspectionStaff extends TenantBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableField("driver_license_type")
|
@TableField("driver_license_type")
|
||||||
private String driverLicenseType;
|
private String driverLicenseType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件夹id
|
||||||
|
*/
|
||||||
|
@TableField("folder_id")
|
||||||
|
private Long folderId;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,14 @@ public interface IInspectionFileService extends IService<InspectionFile>
|
|||||||
* @param inspectionFile inspectionFile
|
* @param inspectionFile inspectionFile
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertInspectionFile(InspectionFile inspectionFile);
|
public InspectionFile insertInspectionFile(InspectionFile inspectionFile);
|
||||||
|
/**
|
||||||
|
* 新增inspectionFile
|
||||||
|
*
|
||||||
|
* @param inspectionFiles inspectionFile
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean insertBatchInspectionFile(List<InspectionFile> inspectionFiles);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改inspectionFile
|
* 修改inspectionFile
|
||||||
|
@ -7,7 +7,6 @@ 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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
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;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@ -26,8 +25,7 @@ import java.util.stream.Collectors;
|
|||||||
* @date 2023-10-13
|
* @date 2023-10-13
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,InspectionFile> implements IInspectionFileService
|
public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper, InspectionFile> implements IInspectionFileService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IWarnMessageService messageService;
|
private IWarnMessageService messageService;
|
||||||
|
|
||||||
@ -38,8 +36,7 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
* @return inspectionFile
|
* @return inspectionFile
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public InspectionFile selectInspectionFileById(Long id)
|
public InspectionFile selectInspectionFileById(Long id) {
|
||||||
{
|
|
||||||
return baseMapper.selectInspectionFileById(id);
|
return baseMapper.selectInspectionFileById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,23 +48,22 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertInspectionFile(InspectionFile inspectionFile)
|
public InspectionFile insertInspectionFile(InspectionFile inspectionFile) {
|
||||||
{
|
|
||||||
|
|
||||||
int insert = baseMapper.insert(inspectionFile);
|
int insert = baseMapper.insert(inspectionFile);
|
||||||
if (ObjectUtil.isEmpty(inspectionFile.getFatherId())){
|
if (ObjectUtil.isEmpty(inspectionFile.getFatherId())) {
|
||||||
inspectionFile.setFileCode(inspectionFile.getId()+",");
|
inspectionFile.setFileCode(inspectionFile.getId() + ",");
|
||||||
}else {
|
} else {
|
||||||
InspectionFile faFile = this.getById(inspectionFile.getFatherId());
|
InspectionFile faFile = this.getById(inspectionFile.getFatherId());
|
||||||
|
|
||||||
inspectionFile.setFileCode(faFile.getFileCode()+inspectionFile.getId()+",");
|
inspectionFile.setFileCode(faFile.getFileCode() + inspectionFile.getId() + ",");
|
||||||
}
|
}
|
||||||
baseMapper.updateById(inspectionFile);
|
baseMapper.updateById(inspectionFile);
|
||||||
if (ObjectUtil.isNotEmpty(inspectionFile.getWarnTime())){
|
if (ObjectUtil.isNotEmpty(inspectionFile.getWarnTime())) {
|
||||||
//同时处理提醒信息
|
//同时处理提醒信息
|
||||||
WarnMessage warnMessage =new WarnMessage();
|
WarnMessage warnMessage = new WarnMessage();
|
||||||
warnMessage.setTitle("文件到期提醒");
|
warnMessage.setTitle("文件到期提醒");
|
||||||
warnMessage.setContent("文件名为:"+inspectionFile.getFileName()+"即将过期,请及时处理相关事项!");
|
warnMessage.setContent("文件名为:" + inspectionFile.getFileName() + "即将过期,请及时处理相关事项!");
|
||||||
warnMessage.setIsRead("0");
|
warnMessage.setIsRead("0");
|
||||||
warnMessage.setPartnerId(inspectionFile.getPartnerId());
|
warnMessage.setPartnerId(inspectionFile.getPartnerId());
|
||||||
warnMessage.setType("file");
|
warnMessage.setType("file");
|
||||||
@ -75,7 +71,42 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
warnMessage.setWarnTime(inspectionFile.getWarnTime());
|
warnMessage.setWarnTime(inspectionFile.getWarnTime());
|
||||||
messageService.save(warnMessage);
|
messageService.save(warnMessage);
|
||||||
}
|
}
|
||||||
return insert;
|
return inspectionFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增inspectionFile
|
||||||
|
*
|
||||||
|
* @param inspectionFiles inspectionFile
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean insertBatchInspectionFile(List<InspectionFile> inspectionFiles) {
|
||||||
|
for (InspectionFile inspectionFile : inspectionFiles) {
|
||||||
|
int insert = baseMapper.insert(inspectionFile);
|
||||||
|
if (ObjectUtil.isEmpty(inspectionFile.getFatherId())) {
|
||||||
|
inspectionFile.setFileCode(inspectionFile.getId() + ",");
|
||||||
|
} else {
|
||||||
|
InspectionFile faFile = this.getById(inspectionFile.getFatherId());
|
||||||
|
|
||||||
|
inspectionFile.setFileCode(faFile.getFileCode() + inspectionFile.getId() + ",");
|
||||||
|
}
|
||||||
|
baseMapper.updateById(inspectionFile);
|
||||||
|
if (ObjectUtil.isNotEmpty(inspectionFile.getWarnTime())) {
|
||||||
|
//同时处理提醒信息
|
||||||
|
WarnMessage warnMessage = new WarnMessage();
|
||||||
|
warnMessage.setTitle("文件到期提醒");
|
||||||
|
warnMessage.setContent("文件名为:" + inspectionFile.getFileName() + "即将过期,请及时处理相关事项!");
|
||||||
|
warnMessage.setIsRead("0");
|
||||||
|
warnMessage.setPartnerId(inspectionFile.getPartnerId());
|
||||||
|
warnMessage.setType("file");
|
||||||
|
warnMessage.setObjectId(inspectionFile.getId());
|
||||||
|
warnMessage.setWarnTime(inspectionFile.getWarnTime());
|
||||||
|
messageService.save(warnMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// return this.saveBatch(inspectionFiles);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,20 +116,19 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateInspectionFile(InspectionFile inspectionFile)
|
public int updateInspectionFile(InspectionFile inspectionFile) {
|
||||||
{
|
LambdaQueryWrapper<WarnMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
LambdaQueryWrapper<WarnMessage> queryWrapper =new LambdaQueryWrapper<>();
|
queryWrapper.eq(WarnMessage::getType, "file").eq(WarnMessage::getObjectId, inspectionFile.getId());
|
||||||
queryWrapper.eq(WarnMessage::getType,"file").eq(WarnMessage::getObjectId,inspectionFile.getId());
|
|
||||||
WarnMessage one = messageService.getOne(queryWrapper);
|
WarnMessage one = messageService.getOne(queryWrapper);
|
||||||
if (ObjectUtil.isNotEmpty(one)){
|
if (ObjectUtil.isNotEmpty(one)) {
|
||||||
//更新处理
|
//更新处理
|
||||||
messageService.removeById(one.getId());
|
messageService.removeById(one.getId());
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotEmpty(inspectionFile.getWarnTime())){
|
if (ObjectUtil.isNotEmpty(inspectionFile.getWarnTime())) {
|
||||||
//同时处理提醒信息
|
//同时处理提醒信息
|
||||||
WarnMessage warnMessage =new WarnMessage();
|
WarnMessage warnMessage = new WarnMessage();
|
||||||
warnMessage.setTitle("文件到期提醒");
|
warnMessage.setTitle("文件到期提醒");
|
||||||
warnMessage.setContent("文件名为:"+inspectionFile.getFileName()+"即将过期,请及时处理相关事项!");
|
warnMessage.setContent("文件名为:" + inspectionFile.getFileName() + "即将过期,请及时处理相关事项!");
|
||||||
warnMessage.setIsRead("0");
|
warnMessage.setIsRead("0");
|
||||||
warnMessage.setPartnerId(inspectionFile.getPartnerId());
|
warnMessage.setPartnerId(inspectionFile.getPartnerId());
|
||||||
warnMessage.setType("file");
|
warnMessage.setType("file");
|
||||||
@ -116,8 +146,7 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteInspectionFileByIds(Long[] ids)
|
public int deleteInspectionFileByIds(Long[] ids) {
|
||||||
{
|
|
||||||
return baseMapper.deleteBatchIds(Arrays.asList(ids));
|
return baseMapper.deleteBatchIds(Arrays.asList(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,27 +157,26 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteInspectionFileById(Long id)
|
public int deleteInspectionFileById(Long id) {
|
||||||
{
|
|
||||||
InspectionFile file = this.getById(id);
|
InspectionFile file = this.getById(id);
|
||||||
if (file.getType().equals("2")){
|
if (file.getType().equals("2")) {
|
||||||
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);
|
||||||
if (ObjectUtil.isNotEmpty(one)){
|
if (ObjectUtil.isNotEmpty(one)) {
|
||||||
//更新处理
|
//更新处理
|
||||||
messageService.removeById(one.getId());
|
messageService.removeById(one.getId());
|
||||||
}
|
}
|
||||||
baseMapper.deleteById(id);
|
baseMapper.deleteById(id);
|
||||||
}else if (file.getType().equals("1")){
|
} else if (file.getType().equals("1")) {
|
||||||
LambdaQueryWrapper<InspectionFile> queryWrapper =new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<InspectionFile> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.likeLeft(InspectionFile::getFileCode,file.getFileCode());
|
queryWrapper.likeLeft(InspectionFile::getFileCode, file.getFileCode());
|
||||||
List<InspectionFile> list = this.list(queryWrapper);
|
List<InspectionFile> list = this.list(queryWrapper);
|
||||||
for (InspectionFile inspectionFile : list) {
|
for (InspectionFile inspectionFile : list) {
|
||||||
LambdaQueryWrapper<WarnMessage> queryWrapper1 =new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WarnMessage> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||||
queryWrapper1.eq(WarnMessage::getType,"file").eq(WarnMessage::getObjectId,inspectionFile.getId());
|
queryWrapper1.eq(WarnMessage::getType, "file").eq(WarnMessage::getObjectId, inspectionFile.getId());
|
||||||
WarnMessage one = messageService.getOne(queryWrapper1);
|
WarnMessage one = messageService.getOne(queryWrapper1);
|
||||||
if (ObjectUtil.isNotEmpty(one)){
|
if (ObjectUtil.isNotEmpty(one)) {
|
||||||
//更新处理
|
//更新处理
|
||||||
messageService.removeById(one.getId());
|
messageService.removeById(one.getId());
|
||||||
}
|
}
|
||||||
@ -168,7 +196,7 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
}
|
}
|
||||||
queryWrapper.orderByAsc(InspectionFile::getType);
|
queryWrapper.orderByAsc(InspectionFile::getType);
|
||||||
queryWrapper.orderByDesc(InspectionFile::getCreateTime);
|
queryWrapper.orderByDesc(InspectionFile::getCreateTime);
|
||||||
if (ObjectUtil.isNotEmpty(inspectionFile.getFileName())){
|
if (ObjectUtil.isNotEmpty(inspectionFile.getFileName())) {
|
||||||
queryWrapper.like(InspectionFile::getFileName, inspectionFile.getFileName());
|
queryWrapper.like(InspectionFile::getFileName, inspectionFile.getFileName());
|
||||||
}
|
}
|
||||||
// 直接调用 MyBatis-Plus 的 page 方法进行分页查询
|
// 直接调用 MyBatis-Plus 的 page 方法进行分页查询
|
||||||
@ -178,12 +206,12 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
|||||||
/**
|
/**
|
||||||
* 根据id统计数量
|
* 根据id统计数量
|
||||||
*
|
*
|
||||||
|
* @param ids ids
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 14:30 2024/12/14
|
* @date 14:30 2024/12/14
|
||||||
* @param ids ids
|
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, Long> getCountByIds(List<Long> ids){
|
public Map<Long, Long> getCountByIds(List<Long> ids) {
|
||||||
List<InspectionFile> inspectionFiles = baseMapper.selectList(new LambdaQueryWrapper<InspectionFile>().in(InspectionFile::getFatherId, ids));
|
List<InspectionFile> inspectionFiles = baseMapper.selectList(new LambdaQueryWrapper<InspectionFile>().in(InspectionFile::getFatherId, ids));
|
||||||
return inspectionFiles.stream().collect(Collectors.groupingBy(
|
return inspectionFiles.stream().collect(Collectors.groupingBy(
|
||||||
InspectionFile::getFatherId,
|
InspectionFile::getFatherId,
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package cn.iocoder.yudao.module.inspection.service.impl;
|
package cn.iocoder.yudao.module.inspection.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
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.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.InspectionPickCar;
|
import cn.iocoder.yudao.module.inspection.entity.InspectionPickCar;
|
||||||
import cn.iocoder.yudao.module.inspection.entity.InspectionStaff;
|
import cn.iocoder.yudao.module.inspection.entity.InspectionStaff;
|
||||||
import cn.iocoder.yudao.module.inspection.mapper.InspectionStaffMapper;
|
import cn.iocoder.yudao.module.inspection.mapper.InspectionStaffMapper;
|
||||||
import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery;
|
import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery;
|
||||||
|
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
|
||||||
import cn.iocoder.yudao.module.inspection.service.InspectionStaffService;
|
import cn.iocoder.yudao.module.inspection.service.InspectionStaffService;
|
||||||
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffExportVo;
|
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffExportVo;
|
||||||
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffSaveVo;
|
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffSaveVo;
|
||||||
@ -26,10 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +52,9 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IInspectionFileService inspectionFileService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取检测员工分页
|
* 获取检测员工分页
|
||||||
*
|
*
|
||||||
@ -81,23 +85,32 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean edit(InspectionStaffSaveVo inspectionStaffVo) {
|
public boolean edit(InspectionStaffSaveVo inspectionStaffVo) {
|
||||||
//更新system_users主表
|
//更新system_users主表
|
||||||
UserSaveReqVO userDTO = BeanUtil.copyProperties(inspectionStaffVo, UserSaveReqVO.class);
|
UserSaveReqVO userDTO = BeanUtil.copyProperties(inspectionStaffVo, UserSaveReqVO.class);
|
||||||
userDTO.setId(inspectionStaffVo.getUserId());
|
userDTO.setId(inspectionStaffVo.getUserId());
|
||||||
userService.updateUser(userDTO);
|
userService.updateUser(userDTO);
|
||||||
|
|
||||||
|
|
||||||
//查询员工子表是否存在数据
|
//查询员工子表是否存在数据
|
||||||
InspectionStaff staff = this.getOne(Wrappers.<InspectionStaff>lambdaQuery().eq(InspectionStaff::getUserId, inspectionStaffVo.getUserId()));
|
InspectionStaff staff = this.getOne(Wrappers.<InspectionStaff>lambdaQuery().eq(InspectionStaff::getUserId, inspectionStaffVo.getUserId()));
|
||||||
if (ObjectUtil.isNull(staff)) {
|
if (ObjectUtil.isNull(staff)) {
|
||||||
InspectionStaff inspectionStaff = BeanUtil.copyProperties(inspectionStaffVo, InspectionStaff.class);
|
staff = new InspectionStaff();
|
||||||
|
BeanUtil.copyProperties(inspectionStaffVo, staff);
|
||||||
//新增
|
//新增
|
||||||
return this.save(inspectionStaff);
|
this.save(staff);
|
||||||
} else {
|
} else {
|
||||||
//更新检测员工子表
|
//更新检测员工子表
|
||||||
BeanUtil.copyProperties(inspectionStaffVo, staff);
|
BeanUtil.copyProperties(inspectionStaffVo, staff);
|
||||||
return this.updateById(staff);
|
this.updateById(staff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//查询文件夹
|
||||||
|
InspectionStaff staff1 = this.getOne(Wrappers.<InspectionStaff>lambdaQuery().eq(InspectionStaff::getUserId, inspectionStaffVo.getUserId()));
|
||||||
|
addFile(inspectionStaffVo.getFileList(), inspectionStaffVo.getNickname(), staff1.getFolderId(), staff1.getUserId());
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,6 +126,22 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
|
|||||||
if (ObjectUtil.isNotEmpty(inspectionStaffSaveVo.getDriverLicenseType())) {
|
if (ObjectUtil.isNotEmpty(inspectionStaffSaveVo.getDriverLicenseType())) {
|
||||||
inspectionStaffSaveVo.setDriverLicenseTypeArr(Arrays.asList(inspectionStaffSaveVo.getDriverLicenseType().split(",")));
|
inspectionStaffSaveVo.setDriverLicenseTypeArr(Arrays.asList(inspectionStaffSaveVo.getDriverLicenseType().split(",")));
|
||||||
}
|
}
|
||||||
|
//查询文件附件
|
||||||
|
if (ObjectUtil.isNotEmpty(inspectionStaffSaveVo.getFolderId())) {
|
||||||
|
List<InspectionFile> fileList = inspectionFileService.list(Wrappers.<InspectionFile>lambdaQuery()
|
||||||
|
.eq(InspectionFile::getFatherId, inspectionStaffSaveVo.getFolderId())
|
||||||
|
.eq(InspectionFile::getIsStaffFile, InspectionConstants.INSPECTION_IS_STAFF_FILE));
|
||||||
|
|
||||||
|
List<FileDO> copyFileList = new ArrayList<>();
|
||||||
|
for (InspectionFile inspectionFile : fileList) {
|
||||||
|
FileDO fileDO = new FileDO();
|
||||||
|
//把文件名后缀截取掉
|
||||||
|
fileDO.setUrl(inspectionFile.getFilePath());
|
||||||
|
fileDO.setName(inspectionFile.getFileName());
|
||||||
|
copyFileList.add(fileDO);
|
||||||
|
}
|
||||||
|
inspectionStaffSaveVo.setFileList(copyFileList);
|
||||||
|
}
|
||||||
return inspectionStaffSaveVo;
|
return inspectionStaffSaveVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,5 +175,65 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
|
|||||||
//新增检测员工子表
|
//新增检测员工子表
|
||||||
return this.save(inspectionStaff);
|
return this.save(inspectionStaff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加员工附件
|
||||||
|
*
|
||||||
|
* @param fileList 文件集合
|
||||||
|
* @param nickname 员工姓名
|
||||||
|
* @param fatherId 父级文件夹id
|
||||||
|
*/
|
||||||
|
public void addFile(List<FileDO> fileList, String nickname, Long fatherId, Long userId) {
|
||||||
|
if (ObjectUtil.isEmpty(fatherId)) {
|
||||||
|
//添加文件夹
|
||||||
|
InspectionFile inspectionFile = new InspectionFile();
|
||||||
|
inspectionFile.setFileName(nickname + InspectionConstants.INSPECTION_FOLDER_SUFFIX);
|
||||||
|
inspectionFile.setType(InspectionConstants.INSPECTION_FOLDER);
|
||||||
|
|
||||||
|
fatherId = inspectionFileService.insertInspectionFile(inspectionFile).getId();
|
||||||
|
|
||||||
|
//更新员工子表中的文件夹id
|
||||||
|
this.update(Wrappers.<InspectionStaff>lambdaUpdate()
|
||||||
|
.eq(InspectionStaff::getUserId, userId)
|
||||||
|
.set(InspectionStaff::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) {
|
||||||
|
int lastDotIndex = filename.lastIndexOf('.');
|
||||||
|
if (lastDotIndex == -1) {
|
||||||
|
return filename; // 如果没有找到点,则返回原文件名
|
||||||
|
}
|
||||||
|
return filename.substring(0, lastDotIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.inspection.vo;
|
package cn.iocoder.yudao.module.inspection.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.annotation.Excel;
|
import cn.iocoder.yudao.annotation.Excel;
|
||||||
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||||
import cn.iocoder.yudao.module.inspection.entity.InspectionStaff;
|
import cn.iocoder.yudao.module.inspection.entity.InspectionStaff;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
@ -97,4 +98,9 @@ public class InspectionStaffSaveVo extends InspectionStaff {
|
|||||||
* 驾驶证类型集合
|
* 驾驶证类型集合
|
||||||
*/
|
*/
|
||||||
private List<String> driverLicenseTypeArr;
|
private List<String> driverLicenseTypeArr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件集合
|
||||||
|
*/
|
||||||
|
private List<FileDO> fileList;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,8 @@
|
|||||||
iss.social_security_buy_date,
|
iss.social_security_buy_date,
|
||||||
iss.emergency_contact_name,
|
iss.emergency_contact_name,
|
||||||
iss.emergency_contact_phone,
|
iss.emergency_contact_phone,
|
||||||
iss.driver_license_type
|
iss.driver_license_type,
|
||||||
|
iss.folder_id
|
||||||
FROM system_users su
|
FROM system_users su
|
||||||
left join system_user_role sur on su.id = sur.user_id
|
left join system_user_role sur on su.id = sur.user_id
|
||||||
left join system_role sr on sur.role_id = sr.id
|
left join system_role sr on sur.role_id = sr.id
|
||||||
|
Loading…
Reference in New Issue
Block a user