安全、质量、进度、施工人员;对象存储添加文件大小

This commit is contained in:
lcj
2025-09-16 15:24:05 +08:00
parent 9d0c66b2d3
commit d66d44460b
30 changed files with 443 additions and 206 deletions

View File

@ -1,6 +1,5 @@
package org.dromara.contractor.controller.app; package org.dromara.contractor.controller.app;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;

View File

@ -2,14 +2,15 @@ package org.dromara.contractor.controller.app;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.web.core.BaseController; import org.dromara.common.web.core.BaseController;
import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileQueryReq; import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileQueryReq;
import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileSaveReq;
import org.dromara.contractor.domain.vo.constructionuserfile.SubConstructionUserFileVo; import org.dromara.contractor.domain.vo.constructionuserfile.SubConstructionUserFileVo;
import org.dromara.contractor.service.ISubConstructionUserFileService; import org.dromara.contractor.service.ISubConstructionUserFileService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -35,4 +36,13 @@ public class SubConstructionUserFileAppController extends BaseController {
return R.ok(constructionUserFileService.queryList(req)); return R.ok(constructionUserFileService.queryList(req));
} }
/**
* 保存施工人员文件存储详情信息
*/
@Log(title = "施工人员文件存储", businessType = BusinessType.INSERT)
@PostMapping("/save")
public R<Boolean> save(@RequestBody SubConstructionUserFileSaveReq req) {
return R.ok(constructionUserFileService.saveFileList(req));
}
} }

View File

@ -47,6 +47,7 @@ public class SubConstructionUserVo implements Serializable {
* 人脸照 url * 人脸照 url
*/ */
@ExcelProperty(value = "人脸照 url") @ExcelProperty(value = "人脸照 url")
@Translation(type = TransConstant.OSS_ID_TO_URL, mapper = "facePic")
private String facePicUrl; private String facePicUrl;
/** /**

View File

@ -10,6 +10,7 @@ import org.dromara.contractor.domain.SubConstructionUserFile;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
@ -51,6 +52,26 @@ public class SubConstructionUserFileVo implements Serializable {
@ExcelProperty(value = "文件路径") @ExcelProperty(value = "文件路径")
private String path; private String path;
/**
* 文件访问地址
*/
private String url;
/**
* 文件名
*/
private String fileName;
/**
* 文件大小
*/
private String fileSize;
/**
* 创建时间
*/
private Date createTime;
/** /**
* 备注 * 备注
*/ */

View File

@ -31,10 +31,13 @@ import org.dromara.project.domain.BusConstructionBlacklist;
import org.dromara.project.domain.BusProject; import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusConstructionBlacklistService; import org.dromara.project.service.IBusConstructionBlacklistService;
import org.dromara.project.service.IBusProjectService; import org.dromara.project.service.IBusProjectService;
import org.dromara.safety.domain.WgzQuestionSavePdf;
import org.dromara.safety.service.IWgzQuestionSavePdfService;
import org.dromara.system.domain.vo.SysDictDataVo; import org.dromara.system.domain.vo.SysDictDataVo;
import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.service.ISysDictTypeService; import org.dromara.system.service.ISysDictTypeService;
import org.dromara.system.service.ISysOssService; import org.dromara.system.service.ISysOssService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -43,10 +46,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -78,6 +78,9 @@ public class SubConstructionUserFileServiceImpl extends ServiceImpl<SubConstruct
@Resource @Resource
private ISysOssService ossService; private ISysOssService ossService;
@Resource
private IWgzQuestionSavePdfService wgzQuestionSavePdfService;
/** /**
* 查询施工人员文件存储 * 查询施工人员文件存储
* *
@ -98,7 +101,73 @@ public class SubConstructionUserFileServiceImpl extends ServiceImpl<SubConstruct
@Override @Override
public List<SubConstructionUserFileVo> queryList(SubConstructionUserFileQueryReq req) { public List<SubConstructionUserFileVo> queryList(SubConstructionUserFileQueryReq req) {
LambdaQueryWrapper<SubConstructionUserFile> lqw = buildQueryWrapper(req); LambdaQueryWrapper<SubConstructionUserFile> lqw = buildQueryWrapper(req);
return baseMapper.selectVoList(lqw); List<SubConstructionUserFileVo> list = baseMapper.selectVoList(lqw);
if (CollUtil.isEmpty(list)) {
return List.of();
}
// 获取oss文件信息
List<Long> files = list.stream().map(SubConstructionUserFileVo::getPath)
.filter(Objects::nonNull)
.flatMap(s -> Arrays.stream(s.split(",")))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.toList();
List<SysOssVo> ossVoList = ossService.listByIds(files);
Map<Long, SysOssVo> ossVoMap = ossVoList.stream()
.collect(Collectors.toMap(SysOssVo::getOssId, Function.identity()));
List<SubConstructionUserFileVo> listVo = new ArrayList<>();
for (SubConstructionUserFileVo file : list) {
if (Objects.equals(file.getFileType(), "11")) {
// 安全考试
WgzQuestionSavePdf wgzQuestionSavePdf = wgzQuestionSavePdfService.queryByUserId(file.getUserId());
if (wgzQuestionSavePdf != null) {
List<SysOssVo> ossVos = ossService.listByIds(Arrays.stream(wgzQuestionSavePdf
.getPath()
.split(","))
.map(Long::parseLong)
.toList());
for (SysOssVo ossVo : ossVos) {
SubConstructionUserFileVo vo = new SubConstructionUserFileVo();
BeanUtils.copyProperties(file, vo);
vo.setUrl(ossVo.getUrl());
vo.setFileName(ossVo.getOriginalName());
vo.setFileSize(ossService.formatFileSize(ossVo.getFileSize()));
listVo.add(vo);
}
}
} else if (Objects.equals(file.getFileType(), "12")) {
// 特种工作证
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(file.getUserId());
List<SysOssVo> ossVos = ossService.listByIds(Arrays.stream(constructionUser
.getSpecialWorkPic()
.split(","))
.map(Long::parseLong).toList());
for (SysOssVo ossVo : ossVos) {
SubConstructionUserFileVo vo = new SubConstructionUserFileVo();
BeanUtils.copyProperties(file, vo);
vo.setUrl(ossVo.getUrl());
vo.setFileName(ossVo.getOriginalName());
vo.setFileSize(ossService.formatFileSize(ossVo.getFileSize()));
listVo.add(vo);
}
} else {
List<Long> ossIds = Arrays.stream(file.getPath().split(",")).map(Long::parseLong).toList();
for (Long ossId : ossIds) {
SubConstructionUserFileVo vo = new SubConstructionUserFileVo();
if (ossVoMap.containsKey(ossId)) {
BeanUtils.copyProperties(file, vo);
SysOssVo ossVo = ossVoMap.get(ossId);
vo.setUrl(ossVo.getUrl());
vo.setFileName(ossVo.getOriginalName());
vo.setFileSize(ossService.formatFileSize(ossVo.getFileSize()));
}
listVo.add(vo);
}
}
}
return listVo;
} }
/** /**

View File

@ -683,11 +683,6 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
constructionUserVo.setContractorName(contractor.getName()); constructionUserVo.setContractorName(contractor.getName());
} }
} }
// 关联查询用户头像url
String facePic = constructionUser.getFacePic();
if (StringUtils.isNotBlank(facePic)) {
constructionUserVo.setFacePicUrl(ossService.getById(Long.parseLong(facePic)).getUrl());
}
// 关联查询薪水标准 // 关联查询薪水标准
String typeOfWork = constructionUser.getTypeOfWork(); String typeOfWork = constructionUser.getTypeOfWork();
String wageMeasureUnit = constructionUser.getWageMeasureUnit(); String wageMeasureUnit = constructionUser.getWageMeasureUnit();
@ -770,12 +765,14 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
.or().isNull(SubConstructionUser::getTeamId)); .or().isNull(SubConstructionUser::getTeamId));
} }
// 查询当前项目下的黑名单人员 // 查询当前项目下的黑名单人员
List<Long> blackUserIdList;
if (projectId != null) { if (projectId != null) {
List<Long> blackUserIdList = constructionBlacklistService.queryIdListByProjectId(projectId); blackUserIdList = constructionBlacklistService.queryIdListByProjectId(projectId);
// 查询结果移除黑名单人员 } else {
if (CollUtil.isNotEmpty(blackUserIdList)) { blackUserIdList = constructionBlacklistService.queryIdListByProjectId(null);
lqw.notIn(SubConstructionUser::getSysUserId, blackUserIdList); }
} if (CollUtil.isNotEmpty(blackUserIdList)) {
lqw.notIn(SubConstructionUser::getSysUserId, blackUserIdList);
} }
lqw.ne(StringUtils.isNotBlank(notUserRole), SubConstructionUser::getUserRole, notUserRole); lqw.ne(StringUtils.isNotBlank(notUserRole), SubConstructionUser::getUserRole, notUserRole);
if (StringUtils.isNotBlank(entryDate)) { if (StringUtils.isNotBlank(entryDate)) {
@ -1036,8 +1033,6 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
} }
/** /**
* 获取施工人员身份证信息 * 获取施工人员身份证信息
* *
@ -1305,19 +1300,20 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
SubConstructionUserAppVo subConstructionUserAppVo = new SubConstructionUserAppVo(); SubConstructionUserAppVo subConstructionUserAppVo = new SubConstructionUserAppVo();
BeanUtils.copyProperties(constructionUser, subConstructionUserAppVo); BeanUtils.copyProperties(constructionUser, subConstructionUserAppVo);
SysUserVo sysUserVo = userService.selectUserById(subConstructionUserAppVo.getSysUserId()); SysUserVo sysUserVo = userService.selectUserById(subConstructionUserAppVo.getSysUserId());
if (sysUserVo.getAvatar() != null) if (sysUserVo != null) {
subConstructionUserAppVo.setAvatar(ossService.getById(sysUserVo.getAvatar()).getUrl()); if (sysUserVo.getAvatar() != null)
//计算日期 subConstructionUserAppVo.setAvatar(ossService.getById(sysUserVo.getAvatar()).getUrl());
Date createTime = sysUserVo.getCreateTime(); //计算日期
Instant createInstant = createTime.toInstant(); Date createTime = sysUserVo.getCreateTime();
Instant nowInstant = Instant.now(); Instant createInstant = createTime.toInstant();
long days = ChronoUnit.DAYS.between( Instant nowInstant = Instant.now();
createInstant.atZone(ZoneId.systemDefault()).toLocalDateTime(), long days = ChronoUnit.DAYS.between(
nowInstant.atZone(ZoneId.systemDefault()).toLocalDateTime() createInstant.atZone(ZoneId.systemDefault()).toLocalDateTime(),
); nowInstant.atZone(ZoneId.systemDefault()).toLocalDateTime()
subConstructionUserAppVo.setDays(days); );
subConstructionUserAppVo.setSex(sysUserVo.getSex()); subConstructionUserAppVo.setDays(days);
subConstructionUserAppVo.setSex(sysUserVo.getSex());
}
list.add(subConstructionUserAppVo); list.add(subConstructionUserAppVo);
} }

View File

@ -7,8 +7,6 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil; import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log; import org.dromara.common.log.annotation.Log;
@ -21,7 +19,6 @@ import org.dromara.progress.domain.dto.constructionscheduleplan.PgsConstructionS
import org.dromara.progress.domain.dto.constructionscheduleplan.PgsConstructionSchedulePlanUpdateReq; import org.dromara.progress.domain.dto.constructionscheduleplan.PgsConstructionSchedulePlanUpdateReq;
import org.dromara.progress.domain.vo.constructionscheduleplan.PgsConstructionSchedulePlanVo; import org.dromara.progress.domain.vo.constructionscheduleplan.PgsConstructionSchedulePlanVo;
import org.dromara.progress.service.IPgsConstructionSchedulePlanService; import org.dromara.progress.service.IPgsConstructionSchedulePlanService;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -83,11 +80,7 @@ public class PgsConstructionSchedulePlanController extends BaseController {
public R<Void> readExcel(@RequestParam("file") MultipartFile file, Long projectId) { public R<Void> readExcel(@RequestParam("file") MultipartFile file, Long projectId) {
List<PgsConstructionSchedulePlanExcelDto> list = pgsConstructionSchedulePlanService.readExcel(file, projectId); List<PgsConstructionSchedulePlanExcelDto> list = pgsConstructionSchedulePlanService.readExcel(file, projectId);
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
List<PgsConstructionSchedulePlan> planList = list.stream().map(dto -> { List<PgsConstructionSchedulePlan> planList = pgsConstructionSchedulePlanService.convertToEntities(list);
PgsConstructionSchedulePlan plan = new PgsConstructionSchedulePlan();
BeanUtils.copyProperties(dto, plan);
return plan;
}).toList();
return toAjax(pgsConstructionSchedulePlanService.saveBatch(planList)); return toAjax(pgsConstructionSchedulePlanService.saveBatch(planList));
} }
return toAjax(true); return toAjax(true);
@ -112,7 +105,7 @@ public class PgsConstructionSchedulePlanController extends BaseController {
@Log(title = "施工进度计划", businessType = BusinessType.INSERT) @Log(title = "施工进度计划", businessType = BusinessType.INSERT)
@RepeatSubmit() @RepeatSubmit()
@PostMapping() @PostMapping()
public R<PgsConstructionSchedulePlanVo> add(@Validated(AddGroup.class) @RequestBody PgsConstructionSchedulePlanCreateReq req) { public R<PgsConstructionSchedulePlanVo> add(@Validated @RequestBody PgsConstructionSchedulePlanCreateReq req) {
return R.ok(pgsConstructionSchedulePlanService.insertByBo(req)); return R.ok(pgsConstructionSchedulePlanService.insertByBo(req));
} }
@ -123,7 +116,7 @@ public class PgsConstructionSchedulePlanController extends BaseController {
@Log(title = "施工进度计划", businessType = BusinessType.UPDATE) @Log(title = "施工进度计划", businessType = BusinessType.UPDATE)
@RepeatSubmit() @RepeatSubmit()
@PutMapping() @PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody PgsConstructionSchedulePlanUpdateReq req) { public R<Void> edit(@Validated @RequestBody PgsConstructionSchedulePlanUpdateReq req) {
return toAjax(pgsConstructionSchedulePlanService.updateByBo(req)); return toAjax(pgsConstructionSchedulePlanService.updateByBo(req));
} }

View File

@ -8,13 +8,17 @@ import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController; import org.dromara.common.web.core.BaseController;
import org.dromara.progress.domain.dto.progressplandetail.*; import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailCreateReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailFinishedCreateReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailQueryReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailRemoveReq;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo;
import org.dromara.progress.service.IPgsProgressPlanDetailService; import org.dromara.progress.service.IPgsProgressPlanDetailService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 进度计划详情 * 进度计划详情
@ -60,14 +64,12 @@ public class PgsProgressPlanDetailController extends BaseController {
} }
/** /**
* 新增进度计划详情(数量设施 * 新增进度计划详情(AI 填报
*/ */
/* @SaCheckPermission("progress:progressPlanDetail:insertNumber") @PostMapping("/insert/numberAI")
@RepeatSubmit() public R<Void> insertNumberDetailByAI(@RequestPart("file") MultipartFile file) {
@PostMapping("/insert/number") return toAjax(pgsProgressPlanDetailService.insertNumberDetailByAI(file));
public R<Void> insertNumberDetail(@Validated @RequestBody PgsProgressPlanDetailNumberCreateReq req) { }
return toAjax(pgsProgressPlanDetailService.insertNumberDetail(req));
}*/
/** /**
* 获取进度计划详情已完成设施详细信息 * 获取进度计划详情已完成设施详细信息

View File

@ -13,16 +13,16 @@ import java.time.LocalDate;
@AllArgsConstructor @AllArgsConstructor
public class PgsConstructionSchedulePlanExcelDto { public class PgsConstructionSchedulePlanExcelDto {
/**
* 编号1, 1.1, 1.1.1
*/
private String number;
/** /**
* 项目ID * 项目ID
*/ */
private Long projectId; private Long projectId;
/**
* 父ID
*/
private Long parentId;
/** /**
* 节点名称 * 节点名称
*/ */

View File

@ -36,6 +36,16 @@ public class PgsConstructionSchedulePlanUpdateReq implements Serializable {
*/ */
private String projectStructureName; private String projectStructureName;
/**
* 预计开始时间
*/
private LocalDate planStartDate;
/**
* 预计结束时间
*/
private LocalDate planEndDate;
/** /**
* 实际开始时间 * 实际开始时间
*/ */

View File

@ -101,4 +101,12 @@ public interface IPgsConstructionSchedulePlanService extends IService<PgsConstru
* @return 读取的数据列表 * @return 读取的数据列表
*/ */
List<PgsConstructionSchedulePlanExcelDto> readExcel(MultipartFile file, Long projectId); List<PgsConstructionSchedulePlanExcelDto> readExcel(MultipartFile file, Long projectId);
/**
* 将Excel数据转换为实体列表
*
* @param excelList Excel数据列表
* @return 实体列表
*/
List<PgsConstructionSchedulePlan> convertToEntities(List<PgsConstructionSchedulePlanExcelDto> excelList);
} }

View File

@ -6,14 +6,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.progress.domain.PgsProgressPlanDetail; import org.dromara.progress.domain.PgsProgressPlanDetail;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailFinishedCreateReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailCreateReq; import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailCreateReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailFinishedCreateReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailQueryReq; import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailQueryReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailRemoveReq; import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailRemoveReq;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
@ -51,14 +52,6 @@ public interface IPgsProgressPlanDetailService extends IService<PgsProgressPlanD
*/ */
Boolean insertPercentageNumberDetail(PgsProgressPlanDetailCreateReq req); Boolean insertPercentageNumberDetail(PgsProgressPlanDetailCreateReq req);
/**
* 插入进度计划详情设施
*
* @param req 插入进度计划详情设施参数
* @return 是否插入成功
*/
// Boolean insertNumberDetail(PgsProgressPlanDetailNumberCreateReq req);
/** /**
* 分页查询进度计划详情已完成设施列表 * 分页查询进度计划详情已完成设施列表
* *
@ -138,4 +131,12 @@ public interface IPgsProgressPlanDetailService extends IService<PgsProgressPlanD
* @return 计划详情设施数量 * @return 计划详情设施数量
*/ */
List<PgsProgressPlanDetailNumVo> queryNumberList(PgsProgressPlanDetailQueryReq req); List<PgsProgressPlanDetailNumVo> queryNumberList(PgsProgressPlanDetailQueryReq req);
/**
* 使用AI识别计划详情设施数量
*
* @param file 文件
* @return 是否成功
*/
Boolean insertNumberDetailByAI(MultipartFile file);
} }

View File

@ -1,6 +1,7 @@
package org.dromara.progress.service.impl; package org.dromara.progress.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
@ -173,7 +174,7 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
return constructionSchedulePlanList.stream().map(this::getVo).toList(); return constructionSchedulePlanList.stream().map(this::getVo).toList();
} }
// region // region 导出 excel
/** /**
* 导出Excel * 导出Excel
@ -228,8 +229,8 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
} }
// 主 Sheet 设置表头 // 主 Sheet 设置表头
Row sheetRow = mainSheet.createRow(0); Row sheetRow = mainSheet.createRow(0);
String[] headers = {"节点名称", "对应项目结构", "对应项目结构编码", "预计开始时间格式2025-09-06", String[] headers = {"编号格式11-11-1-1。用于进行父子结构关联", "节点名称", "对应项目结构", "对应项目结构编码",
"预计结束时间", "实际开始时间", "实际结束时间", "状态", "状态编码", "备注"}; "预计开始时间格式2025-09-06", "预计结束时间", "实际开始时间", "实际结束时间", "状态", "状态编码", "备注"};
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
Cell cell = sheetRow.createCell(i); Cell cell = sheetRow.createCell(i);
cell.setCellValue(headers[i]); cell.setCellValue(headers[i]);
@ -237,26 +238,26 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
// 6. 设置专业下拉列表(第二列) // 6. 设置专业下拉列表(第二列)
setMajorDropdown(mainSheet, projectStructureMap.size()); setMajorDropdown(mainSheet, projectStructureMap.size());
setStatusDropdown(mainSheet, statusMap.size()); setStatusDropdown(mainSheet, statusMap.size());
String formulaTemplate = "IFERROR(INDEX(DropdownData!$B$1:$B$" + projectStructureMap.size() + ", MATCH(B{rowNum}, DropdownData!$A$1:$A$" + projectStructureMap.size() + ", 0)),\"\")"; String formulaTemplate = "IFERROR(INDEX(DropdownData!$B$1:$B$" + projectStructureMap.size() + ", MATCH(C{rowNum}, DropdownData!$A$1:$A$" + projectStructureMap.size() + ", 0)),\"\")";
String formulaTemplate1 = "IFERROR(INDEX(DropdownData!$F$1:$F$" + statusMap.size() + ", MATCH(H{rowNum}, DropdownData!$E$1:$E$" + statusMap.size() + ", 0)),\"\")"; String formulaTemplate1 = "IFERROR(INDEX(DropdownData!$F$1:$F$" + statusMap.size() + ", MATCH(I{rowNum}, DropdownData!$E$1:$E$" + statusMap.size() + ", 0)),\"\")";
for (int i = 1; i <= 1000; i++) { // 从第2行到101行 for (int i = 1; i <= 1000; i++) { // 从第2行到101行
Row row = mainSheet.createRow(i); Row row = mainSheet.createRow(i);
int currentRowNum = i + 1; // Excel行号从1开始 int currentRowNum = i + 1; // Excel行号从1开始
String formula = formulaTemplate.replace("{rowNum}", String.valueOf(currentRowNum)); String formula = formulaTemplate.replace("{rowNum}", String.valueOf(currentRowNum));
Cell cell = row.createCell(1); Cell cell = row.createCell(2);
cell.setCellStyle(editableStyle); //专业不锁定 cell.setCellStyle(editableStyle); //专业不锁定
Cell idCell = row.createCell(2); Cell idCell = row.createCell(3);
idCell.setCellFormula(formula); idCell.setCellFormula(formula);
idCell.setCellStyle(protectedStyle); // 应用隐藏公式样式 idCell.setCellStyle(protectedStyle); // 应用隐藏公式样式
String formula1 = formulaTemplate1.replace("{rowNum}", String.valueOf(currentRowNum)); String formula1 = formulaTemplate1.replace("{rowNum}", String.valueOf(currentRowNum));
Cell cell1 = row.createCell(7); Cell cell1 = row.createCell(8);
cell1.setCellStyle(editableStyle); //专业不锁定 cell1.setCellStyle(editableStyle); //专业不锁定
Cell idCell1 = row.createCell(8); Cell idCell1 = row.createCell(9);
idCell1.setCellFormula(formula1); idCell1.setCellFormula(formula1);
idCell1.setCellStyle(protectedStyle); // 应用隐藏公式样式 idCell1.setCellStyle(protectedStyle); // 应用隐藏公式样式
@ -271,8 +272,8 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
Cell cell = row.createCell(0); Cell cell = row.createCell(0);
cell.setCellStyle(editableStyle); cell.setCellStyle(editableStyle);
Cell cell3 = row.createCell(3); Cell cell1 = row.createCell(1);
cell3.setCellStyle(editableStyle); cell1.setCellStyle(editableStyle);
Cell cell4 = row.createCell(4); Cell cell4 = row.createCell(4);
cell4.setCellStyle(editableStyle); cell4.setCellStyle(editableStyle);
@ -283,8 +284,11 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
Cell cell6 = row.createCell(6); Cell cell6 = row.createCell(6);
cell6.setCellStyle(editableStyle); cell6.setCellStyle(editableStyle);
Cell cell9 = row.createCell(9); Cell cell7 = row.createCell(7);
cell9.setCellStyle(editableStyle); cell7.setCellStyle(editableStyle);
Cell cell10 = row.createCell(10);
cell10.setCellStyle(editableStyle);
} }
@ -307,6 +311,7 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
mainSheet.setColumnWidth(7, 20 * 200); mainSheet.setColumnWidth(7, 20 * 200);
mainSheet.setColumnWidth(8, 20 * 100); mainSheet.setColumnWidth(8, 20 * 100);
mainSheet.setColumnWidth(9, 20 * 200); mainSheet.setColumnWidth(9, 20 * 200);
mainSheet.setColumnWidth(10, 20 * 200);
// 直接写入响应输出流 // 直接写入响应输出流
try { try {
@ -352,7 +357,7 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
DataValidationConstraint constraint = helper.createFormulaListConstraint(majorRange); DataValidationConstraint constraint = helper.createFormulaListConstraint(majorRange);
// 作用范围第2行到100行第二列 // 作用范围第2行到100行第二列
CellRangeAddressList addressList = new CellRangeAddressList(1, 1000, 1, 1); CellRangeAddressList addressList = new CellRangeAddressList(1, 1000, 2, 2);
DataValidation validation = helper.createValidation(constraint, addressList); DataValidation validation = helper.createValidation(constraint, addressList);
validation.setShowErrorBox(true); validation.setShowErrorBox(true);
@ -371,7 +376,7 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
DataValidationConstraint constraint = helper.createFormulaListConstraint(majorRange); DataValidationConstraint constraint = helper.createFormulaListConstraint(majorRange);
// 作用范围第2行到100行第二列 // 作用范围第2行到100行第二列
CellRangeAddressList addressList = new CellRangeAddressList(1, 1000, 7, 7); CellRangeAddressList addressList = new CellRangeAddressList(1, 1000, 8, 8);
DataValidation validation = helper.createValidation(constraint, addressList); DataValidation validation = helper.createValidation(constraint, addressList);
validation.setShowErrorBox(true); validation.setShowErrorBox(true);
@ -402,19 +407,19 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) { for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
Row row = sheet.getRow(rowIndex); Row row = sheet.getRow(rowIndex);
if (hasValidData(row)) { if (hasValidData(row)) {
String number = getCellValue(row.getCell(0));
String nodeName = getCellValue(row.getCell(0)); String nodeName = getCellValue(row.getCell(1));
String projectStructureName = getCellValue(row.getCell(1)); String projectStructureName = getCellValue(row.getCell(2));
Long projectStructure = Long.valueOf(getCellValue(row.getCell(2))); Long projectStructure = Long.valueOf(getCellValue(row.getCell(3)));
LocalDate planStartDate = getLocalDateValue(row.getCell(3)); LocalDate planStartDate = getLocalDateValue(row.getCell(4));
LocalDate planEndDate = getLocalDateValue(row.getCell(4)); LocalDate planEndDate = getLocalDateValue(row.getCell(5));
LocalDate practicalStartDate = getLocalDateValue(row.getCell(5)); LocalDate practicalStartDate = getLocalDateValue(row.getCell(6));
LocalDate practicalEndDate = getLocalDateValue(row.getCell(6)); LocalDate practicalEndDate = getLocalDateValue(row.getCell(7));
String status = getCellValue(row.getCell(8)); String status = getCellValue(row.getCell(9));
String remark = getCellValue(row.getCell(9)); String remark = getCellValue(row.getCell(10));
PgsConstructionSchedulePlanExcelDto excelData = new PgsConstructionSchedulePlanExcelDto( PgsConstructionSchedulePlanExcelDto excelData = new PgsConstructionSchedulePlanExcelDto(
projectId, 0L, nodeName, projectStructure, projectStructureName, number, projectId, nodeName, projectStructure, projectStructureName,
planStartDate, planEndDate, practicalStartDate, practicalEndDate, status, remark planStartDate, planEndDate, practicalStartDate, practicalEndDate, status, remark
); );
dataList.add(excelData); dataList.add(excelData);
@ -428,6 +433,61 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
return dataList; return dataList;
} }
/**
* 将Excel数据转换为实体列表
*
* @param excelList Excel数据列表
* @return 实体列表
*/
@Override
public List<PgsConstructionSchedulePlan> convertToEntities(List<PgsConstructionSchedulePlanExcelDto> excelList) {
List<PgsConstructionSchedulePlan> result = new ArrayList<>();
Map<String, Long> numberIdMap = new HashMap<>();
for (PgsConstructionSchedulePlanExcelDto dto : excelList) {
PgsConstructionSchedulePlan entity = new PgsConstructionSchedulePlan();
LocalDate planStartDate = dto.getPlanStartDate();
LocalDate planEndDate = dto.getPlanEndDate();
if (planStartDate == null || planEndDate == null || planStartDate.isAfter(planEndDate)) {
throw new ServiceException("计划开始时间和计划结束时间不能为空,且计划开始时间不能大于计划结束时间", HttpStatus.BAD_REQUEST);
}
// 生成主键
Long id = IdWorker.getId();
entity.setId(id);
entity.setProjectId(dto.getProjectId());
entity.setNodeName(dto.getNodeName());
entity.setProjectStructure(dto.getProjectStructure());
entity.setProjectStructureName(dto.getProjectStructureName());
entity.setPlanStartDate(planStartDate);
entity.setPlanEndDate(planEndDate);
entity.setPracticalStartDate(dto.getPracticalStartDate());
entity.setPracticalEndDate(dto.getPracticalEndDate());
entity.setStatus(dto.getStatus());
entity.setRemark(dto.getRemark());
// 确定父ID
String number = dto.getNumber();
if (number != null && number.contains("-")) {
String parentNumber = number.substring(0, number.lastIndexOf("-"));
Long parentId = numberIdMap.get(parentNumber);
if (parentId == null) {
throw new ServiceException("未找到父编号:" + parentNumber, HttpStatus.BAD_REQUEST);
}
entity.setParentId(parentId);
} else {
entity.setParentId(0L); // 顶级节点
}
// 保存当前编号对应的id
numberIdMap.put(number, entity.getId());
result.add(entity);
}
return result;
}
private static boolean hasValidData(Row row) { private static boolean hasValidData(Row row) {
// 遍历行中的所有单元格 // 遍历行中的所有单元格
for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) { for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {

View File

@ -143,8 +143,11 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
public List<PgsProgressCategoryVo> queryListByParent(PgsProgressCategoryQueryByParentReq req) { public List<PgsProgressCategoryVo> queryListByParent(PgsProgressCategoryQueryByParentReq req) {
Long parentId = req.getParentId(); Long parentId = req.getParentId();
String name = req.getName(); String name = req.getName();
if (parentId == null) {
return List.of();
}
QueryWrapper<PgsProgressCategory> queryWrapper = new QueryWrapper<>(); QueryWrapper<PgsProgressCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.apply(parentId != null, "FIND_IN_SET({0}, ancestors)", parentId); queryWrapper.apply("FIND_IN_SET({0}, ancestors)", parentId);
queryWrapper.like(StringUtils.isNotBlank(name), "name", name); queryWrapper.like(StringUtils.isNotBlank(name), "name", name);
return this.getVoList(this.list(queryWrapper)); return this.getVoList(this.list(queryWrapper));
} }
@ -524,6 +527,21 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
throw new ServiceException("超过最大层级", HttpStatus.BAD_REQUEST); throw new ServiceException("超过最大层级", HttpStatus.BAD_REQUEST);
} }
progressCategory.setAncestors(ancestors + StringUtils.SEPARATOR + progressCategory.getParentId()); progressCategory.setAncestors(ancestors + StringUtils.SEPARATOR + progressCategory.getParentId());
// 修改关联结构
String parentRelevancyStructure = parent.getRelevancyStructure();
String oldRelevancyStructure = oldProgressCategory.getRelevancyStructure();
progressCategory.setRelevancyStructure(parentRelevancyStructure);
if (!oldRelevancyStructure.equals(parentRelevancyStructure)) {
if (oldRelevancyStructure.equals(PgsRelevancyStructureEnum.MATRIX.getValue())
&& parentRelevancyStructure.equals(PgsRelevancyStructureEnum.SUB_PROJECT.getValue())) {
progressCategory.setMatrixId(0L);
progressCategory.setMatrixName(null);
} else if (oldRelevancyStructure.equals(PgsRelevancyStructureEnum.SUB_PROJECT.getValue())
&& parentRelevancyStructure.equals(PgsRelevancyStructureEnum.MATRIX.getValue())) {
progressCategory.setMatrixId(parent.getMatrixId());
progressCategory.setMatrixName(parent.getMatrixName());
}
}
} }
// 写入数据库 // 写入数据库
boolean result = this.updateById(progressCategory); boolean result = this.updateById(progressCategory);

View File

@ -46,6 +46,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -397,75 +398,6 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
return true; return true;
} }
/**
* 插入进度计划详情设施
*
* @param req 插入进度计划详情设施参数
* @return 是否插入成功
*/
/*@Override
public Boolean insertNumberDetail(PgsProgressPlanDetailNumberCreateReq req) {
// 校验
BigDecimal finishedNumber = req.getFinishedNumber();
// 判断是否小于 0
if (finishedNumber.compareTo(BigDecimal.ZERO) < 0) {
throw new ServiceException("完成数量不能小于0", HttpStatus.BAD_REQUEST);
}
Long id = req.getId();
PgsProgressPlanDetail progressPlanDetail = this.getById(id);
if (progressPlanDetail == null) {
throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND);
}
Long progressPlanId = progressPlanDetail.getProgressPlanId();
PgsProgressPlan progressPlan = progressPlanService.getById(progressPlanId);
if (progressPlan == null) {
throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND);
}
Long progressCategoryId = progressPlanDetail.getProgressCategoryId();
PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId);
if (progressCategory == null) {
throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND);
}
// 校验:总完成数不能超过总计划数
BigDecimal number = progressPlanDetail.getFinishedNumber(); // 旧的完成数
BigDecimal oldFinishedNumberTotal = progressPlan.getFinishedNumber();
BigDecimal newFinishedNumberTotal = oldFinishedNumberTotal.subtract(number).add(finishedNumber);
if (newFinishedNumberTotal.compareTo(progressPlan.getPlanNumber()) > 0) {
throw new ServiceException("总完成数量不能超过计划数量", HttpStatus.BAD_REQUEST);
}
// 更新 detail
progressPlanDetail.setFinishedNumber(finishedNumber);
boolean update = this.updateById(progressPlanDetail);
if (!update) {
throw new ServiceException("更新进度计划详情异常", HttpStatus.ERROR);
}
// 更新 plan
progressPlan.setFinishedNumber(newFinishedNumberTotal);
boolean result = progressPlanService.updateById(progressPlan);
if (!result) {
throw new ServiceException("更新进度计划异常", HttpStatus.ERROR);
}
// 更新 category
BigDecimal completed = progressCategory.getCompleted();
BigDecimal completedTotal = completed.subtract(number).add(finishedNumber);
progressCategory.setCompleted(completedTotal);
// 如果完成数量 >= 总数量,标记为完成
if (completedTotal.compareTo(progressCategory.getTotal()) >= 0) {
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
}
// 判断当前是否已完成计划数量
BigDecimal nowFinishedNumber = progressPlan.getFinishedNumber();
if (oldFinishedNumberTotal.compareTo(progressPlan.getPlanNumber()) < 0
&& nowFinishedNumber.compareTo(progressPlan.getPlanNumber()) >= 0) {
progressCategory.setPlanTotal(progressCategory.getPlanTotal().subtract(progressPlan.getPlanNumber()));
}
boolean updateCategory = progressCategoryService.updateById(progressCategory);
if (!updateCategory) {
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
}
return true;
}*/
/** /**
* 分页查询进度计划详情设施列表 * 分页查询进度计划详情设施列表
* *
@ -954,6 +886,17 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
return getNumVoList(progressPlanDetailList); return getNumVoList(progressPlanDetailList);
} }
/**
* 使用AI识别计划详情设施数量
*
* @param file 文件
* @return 是否成功
*/
@Override
public Boolean insertNumberDetailByAI(MultipartFile file) {
return null;
}
/** /**
* 分页 * 分页
* *

View File

@ -7,12 +7,10 @@ import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType; import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.web.core.BaseController; import org.dromara.common.web.core.BaseController;
import org.dromara.project.domain.dto.constructionuserexit.BusConstructionUserExitCreateReq; import org.dromara.project.domain.dto.constructionuserexit.BusConstructionUserExitCreateReq;
import org.dromara.project.domain.dto.constructionuserexit.BusConstructionUserExitUpdateReq;
import org.dromara.project.service.IBusConstructionUserExitService; import org.dromara.project.service.IBusConstructionUserExitService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 施工人员入场退场记录信息 app 接口 * 施工人员入场退场记录信息 app 接口
@ -38,4 +36,14 @@ public class BusConstructionUserExitAppController extends BaseController {
return toAjax(constructionUserExitService.addRecord(req)); return toAjax(constructionUserExitService.addRecord(req));
} }
/**
* 修改施工人员退场记录信息
*/
@Log(title = "施工人员入场退场记录信息", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> updateExitRecord(@Validated @RequestBody BusConstructionUserExitUpdateReq req) {
return toAjax(constructionUserExitService.updateRecord(req));
}
} }

View File

@ -18,10 +18,10 @@ public class BusConstructionUserExitUpdateReq implements Serializable {
private static final long serialVersionUID = 6818895534694076391L; private static final long serialVersionUID = 6818895534694076391L;
/** /**
* 主键 * 用户id
*/ */
@NotNull(message = "主键不能为空") @NotNull(message = "用户id不能为空")
private Long id; private Long userId;
/** /**
* 工资发放凭证 * 工资发放凭证

View File

@ -13,6 +13,7 @@ import org.dromara.common.core.utils.ObjectUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.utils.IdCardEncryptorUtil;
import org.dromara.contractor.domain.SubConstructionUser; import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.service.ISubConstructionUserService; import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.project.domain.BusConstructionUserExit; import org.dromara.project.domain.BusConstructionUserExit;
@ -55,6 +56,9 @@ public class BusConstructionUserExitServiceImpl extends ServiceImpl<BusConstruct
@Resource @Resource
private ISubConstructionUserService constructionUserService; private ISubConstructionUserService constructionUserService;
@Resource
private IdCardEncryptorUtil idCardEncryptorUtil;
/** /**
* 查询施工人员入场退场记录信息 * 查询施工人员入场退场记录信息
* *
@ -200,11 +204,15 @@ public class BusConstructionUserExitServiceImpl extends ServiceImpl<BusConstruct
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(userId); SubConstructionUser constructionUser = constructionUserService.getBySysUserId(userId);
BusConstructionUserExit constructionUserExit = new BusConstructionUserExit(); BusConstructionUserExit constructionUserExit = new BusConstructionUserExit();
constructionUserExit.setProjectId(constructionUser.getProjectId()); constructionUserExit.setProjectId(constructionUser.getProjectId());
constructionUserExit.setUserId(constructionUser.getId()); constructionUserExit.setUserId(constructionUser.getSysUserId());
constructionUserExit.setSalaryVoucherFile(salaryVoucherFile); constructionUserExit.setSalaryVoucherFile(salaryVoucherFile);
constructionUserExit.setSalaryConfirmationFile(salaryConfirmationFile); constructionUserExit.setSalaryConfirmationFile(salaryConfirmationFile);
constructionUserExit.setTeamId(constructionUser.getTeamId()); constructionUserExit.setTeamId(constructionUser.getTeamId());
constructionUserExit.setSfzNumber(constructionUser.getSfzNumber()); String sfzNumber = constructionUser.getSfzNumber();
if (StringUtils.isNotBlank(sfzNumber)) {
sfzNumber = idCardEncryptorUtil.decrypt(sfzNumber);
constructionUserExit.setSfzNumber(sfzNumber);
}
constructionUserExit.setEntryDate(constructionUser.getEntryDate()); constructionUserExit.setEntryDate(constructionUser.getEntryDate());
constructionUserExit.setLeaveDate(new Date()); constructionUserExit.setLeaveDate(new Date());
constructionUserExit.setRemark(req.getRemark()); constructionUserExit.setRemark(req.getRemark());
@ -238,13 +246,17 @@ public class BusConstructionUserExitServiceImpl extends ServiceImpl<BusConstruct
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean updateRecord(BusConstructionUserExitUpdateReq req) { public Boolean updateRecord(BusConstructionUserExitUpdateReq req) {
Long id = req.getId(); Long userId = req.getUserId();
BusConstructionUserExit constructionUserExit = this.getById(id); BusConstructionUserExit constructionUserExit = this.lambdaQuery()
.eq(BusConstructionUserExit::getUserId, userId)
.orderByDesc(BusConstructionUserExit::getId)
.last("limit 1")
.one();
if (constructionUserExit == null) { if (constructionUserExit == null) {
throw new ServiceException("施工人员入场退场记录不存在", HttpStatus.NOT_FOUND); throw new ServiceException("施工人员入场退场记录不存在", HttpStatus.NOT_FOUND);
} }
BusConstructionUserExit update = new BusConstructionUserExit(); BusConstructionUserExit update = new BusConstructionUserExit();
update.setId(id); update.setId(constructionUserExit.getId());
update.setSalaryVoucherFile(req.getSalaryVoucherFile()); update.setSalaryVoucherFile(req.getSalaryVoucherFile());
update.setSalaryConfirmationFile(req.getSalaryConfirmationFile()); update.setSalaryConfirmationFile(req.getSalaryConfirmationFile());
update.setRemark(req.getRemark()); update.setRemark(req.getRemark());
@ -253,10 +265,10 @@ public class BusConstructionUserExitServiceImpl extends ServiceImpl<BusConstruct
throw new ServiceException("施工人员入场退场记录修改失败", HttpStatus.ERROR); throw new ServiceException("施工人员入场退场记录修改失败", HttpStatus.ERROR);
} }
// 同步修改用户表信息 // 同步修改用户表信息
SubConstructionUser user = new SubConstructionUser(); LambdaUpdateWrapper<SubConstructionUser> luw = new LambdaUpdateWrapper<>();
user.setId(constructionUserExit.getUserId()); luw.eq(SubConstructionUser::getSysUserId, constructionUserExit.getUserId())
user.setExitStatus("2"); .set(SubConstructionUser::getExitStatus, "2");
boolean resultUser = constructionUserService.updateById(user); boolean resultUser = constructionUserService.update(luw);
if (!resultUser) { if (!resultUser) {
throw new ServiceException("施工人员入场退场记录修改失败", HttpStatus.ERROR); throw new ServiceException("施工人员入场退场记录修改失败", HttpStatus.ERROR);
} }

View File

@ -306,7 +306,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(memberId); SubConstructionUser constructionUser = constructionUserService.getBySysUserId(memberId);
BusConstructionUserExit constructionUserExit = new BusConstructionUserExit(); BusConstructionUserExit constructionUserExit = new BusConstructionUserExit();
constructionUserExit.setProjectId(constructionUser.getProjectId()); constructionUserExit.setProjectId(constructionUser.getProjectId());
constructionUserExit.setUserId(constructionUser.getId()); constructionUserExit.setUserId(constructionUser.getSysUserId());
constructionUserExit.setSalaryVoucherFile(salaryVoucherFile); constructionUserExit.setSalaryVoucherFile(salaryVoucherFile);
constructionUserExit.setSalaryConfirmationFile(salaryConfirmationFile); constructionUserExit.setSalaryConfirmationFile(salaryConfirmationFile);
constructionUserExit.setTeamId(constructionUser.getTeamId()); constructionUserExit.setTeamId(constructionUser.getTeamId());

View File

@ -101,7 +101,7 @@ public class HseViolationRecord extends BaseEntity {
private String review; private String review;
/** /**
* 复查状态1通过 2未通过 * 复查状态(0未复查 1通过 2未通过
*/ */
private String reviewType; private String reviewType;
@ -116,7 +116,7 @@ public class HseViolationRecord extends BaseEntity {
private String processType; private String processType;
/** /**
* 工单状态1通知 2整改 3复查 * 工单状态(0待处理 1通知 2整改 3复查
*/ */
private String status; private String status;

View File

@ -41,4 +41,9 @@ public class HseViolationRecordQueryReq implements Serializable {
*/ */
private Long rectificationId; private Long rectificationId;
/**
* 整改人id
*/
private Long correctorId;
} }

View File

@ -9,6 +9,7 @@ import lombok.Getter;
@Getter @Getter
public enum HseSafetyInspectionReviewTypeEnum { public enum HseSafetyInspectionReviewTypeEnum {
NOT_REVIEW("未审核", "0"),
PASS("通过", "1"), PASS("通过", "1"),
UNPASS("未通过", "2"); UNPASS("未通过", "2");

View File

@ -9,6 +9,7 @@ import lombok.Getter;
@Getter @Getter
public enum HseSafetyInspectionStatusEnum { public enum HseSafetyInspectionStatusEnum {
PENDING("待处理", "0"),
INFORM("通知", "1"), INFORM("通知", "1"),
RECTIFICATION("整改", "2"), RECTIFICATION("整改", "2"),
REVIEW("复查", "3"); REVIEW("复查", "3");

View File

@ -106,13 +106,24 @@ public class HseViolationRecordVo implements Serializable {
*/ */
private Date rectificationTime; private Date rectificationTime;
/**
* 整改附件
*/
private String rectificationFile;
/**
* 整改附件url
*/
@Translation(type = TransConstant.OSS_ID_TO_URL, mapper = "rectificationFile")
private String rectificationFileUrl;
/** /**
* 复查情况 * 复查情况
*/ */
private String review; private String review;
/** /**
* 复查状态1通过 2未通过 * 复查状态(0未复查 1通过 2未通过
*/ */
private String reviewType; private String reviewType;
@ -127,7 +138,7 @@ public class HseViolationRecordVo implements Serializable {
private String processType; private String processType;
/** /**
* 工单状态1通知 2整改 3复查 * 工单状态(0待处理 1通知 2整改 3复查
*/ */
private String status; private String status;

View File

@ -27,7 +27,9 @@ import org.dromara.common.utils.DocumentUtil;
import org.dromara.contractor.domain.SubContractor; import org.dromara.contractor.domain.SubContractor;
import org.dromara.contractor.service.ISubContractorService; import org.dromara.contractor.service.ISubContractorService;
import org.dromara.project.domain.BusProjectTeam; import org.dromara.project.domain.BusProjectTeam;
import org.dromara.project.domain.BusProjectTeamMember;
import org.dromara.project.service.IBusProjectService; import org.dromara.project.service.IBusProjectService;
import org.dromara.project.service.IBusProjectTeamMemberService;
import org.dromara.project.service.IBusProjectTeamService; import org.dromara.project.service.IBusProjectTeamService;
import org.dromara.safety.constant.HseSafetyConstant; import org.dromara.safety.constant.HseSafetyConstant;
import org.dromara.safety.domain.HseSafetyInspection; import org.dromara.safety.domain.HseSafetyInspection;
@ -42,7 +44,6 @@ import org.dromara.safety.mapper.HseSafetyInspectionMapper;
import org.dromara.safety.service.IHseSafetyInspectionService; import org.dromara.safety.service.IHseSafetyInspectionService;
import org.dromara.safety.service.IHseTeamMeetingService; import org.dromara.safety.service.IHseTeamMeetingService;
import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.service.ISysDictDataService; import org.dromara.system.service.ISysDictDataService;
import org.dromara.system.service.ISysOssService; import org.dromara.system.service.ISysOssService;
import org.dromara.system.service.ISysUserService; import org.dromara.system.service.ISysUserService;
@ -60,7 +61,6 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
/** /**
@ -98,6 +98,9 @@ public class HseSafetyInspectionServiceImpl extends ServiceImpl<HseSafetyInspect
@Resource @Resource
private ChatServerHandler chatServerHandler; private ChatServerHandler chatServerHandler;
@Resource
private IBusProjectTeamMemberService projectTeamMemberService;
/** /**
* 查询安全巡检工单 * 查询安全巡检工单
* *
@ -122,7 +125,18 @@ public class HseSafetyInspectionServiceImpl extends ServiceImpl<HseSafetyInspect
*/ */
@Override @Override
public TableDataInfo<HseSafetyInspectionVo> queryPageList(HseSafetyInspectionQueryReq req, PageQuery pageQuery) { public TableDataInfo<HseSafetyInspectionVo> queryPageList(HseSafetyInspectionQueryReq req, PageQuery pageQuery) {
Page<HseSafetyInspection> result = this.page(pageQuery.build(), buildQueryWrapper(req)); LambdaQueryWrapper<HseSafetyInspection> lqw = this.buildQueryWrapper(req);
Long userId = LoginHelper.getUserId();
if (userId != null) {
BusProjectTeamMember one = projectTeamMemberService.lambdaQuery()
.eq(BusProjectTeamMember::getMemberId, userId)
.eq(BusProjectTeamMember::getPostId, "0")
.one();
if (one != null) {
lqw.eq(HseSafetyInspection::getCorrectorId, userId);
}
}
Page<HseSafetyInspection> result = this.page(pageQuery.build(), lqw);
return TableDataInfo.build(this.getVoPage(result)); return TableDataInfo.build(this.getVoPage(result));
} }
@ -359,13 +373,6 @@ public class HseSafetyInspectionServiceImpl extends ServiceImpl<HseSafetyInspect
if (CollUtil.isEmpty(safetyInspectionList)) { if (CollUtil.isEmpty(safetyInspectionList)) {
return safetyInspectionVoPage; return safetyInspectionVoPage;
} }
// 获取整改人、创建用户信息
List<Long> userIdList = Stream.concat(
safetyInspectionList.stream().map(HseSafetyInspection::getCorrectorId),
safetyInspectionList.stream().map(HseSafetyInspection::getCreateBy)
).distinct().toList();
List<SysUserVo> userVoList = userService.selectUserByIds(userIdList, null);
Map<Long, String> userMap = userVoList.stream().collect(Collectors.toMap(SysUserVo::getUserId, SysUserVo::getNickName));
// 对象列表 => 封装对象列表 // 对象列表 => 封装对象列表
List<HseSafetyInspectionVo> safetyInspectionVoList = safetyInspectionList.stream().map(inspection -> { List<HseSafetyInspectionVo> safetyInspectionVoList = safetyInspectionList.stream().map(inspection -> {
HseSafetyInspectionVo qualityInspectionVo = new HseSafetyInspectionVo(); HseSafetyInspectionVo qualityInspectionVo = new HseSafetyInspectionVo();
@ -463,10 +470,9 @@ public class HseSafetyInspectionServiceImpl extends ServiceImpl<HseSafetyInspect
Long correctorId = safetyInspection.getCorrectorId(); Long correctorId = safetyInspection.getCorrectorId();
// 只有指定用户可以整改 // 只有指定用户可以整改
Long userId = LoginHelper.getUserId(); Long userId = LoginHelper.getUserId();
// todo 仅测试 if (!correctorId.equals(userId)) {
/* if (!correctorId.equals(userId)) {
throw new ServiceException("当前用户不是指定整改人", HttpStatus.BAD_REQUEST); throw new ServiceException("当前用户不是指定整改人", HttpStatus.BAD_REQUEST);
}*/ }
HseSafetyInspection updateInspection = new HseSafetyInspection(); HseSafetyInspection updateInspection = new HseSafetyInspection();
BeanUtils.copyProperties(req, updateInspection); BeanUtils.copyProperties(req, updateInspection);
if (safetyInspection.getCreateBy() != null && safetyInspection.getIsReply().equals("1")) { if (safetyInspection.getCreateBy() != null && safetyInspection.getIsReply().equals("1")) {

View File

@ -19,11 +19,14 @@ import org.dromara.common.sse.config.SseProperties;
import org.dromara.common.sse.dto.SeeMessageContentDto; import org.dromara.common.sse.dto.SeeMessageContentDto;
import org.dromara.common.sse.dto.SseMessageDto; import org.dromara.common.sse.dto.SseMessageDto;
import org.dromara.common.sse.utils.SseMessageUtils; import org.dromara.common.sse.utils.SseMessageUtils;
import org.dromara.project.domain.BusProjectTeamMember;
import org.dromara.project.service.IBusProjectTeamMemberService;
import org.dromara.safety.domain.HseRecognizeRecord; import org.dromara.safety.domain.HseRecognizeRecord;
import org.dromara.safety.domain.HseViolationLevel; import org.dromara.safety.domain.HseViolationLevel;
import org.dromara.safety.domain.HseViolationLevelPost; import org.dromara.safety.domain.HseViolationLevelPost;
import org.dromara.safety.domain.HseViolationRecord; import org.dromara.safety.domain.HseViolationRecord;
import org.dromara.safety.domain.dto.violationrecord.*; import org.dromara.safety.domain.dto.violationrecord.*;
import org.dromara.safety.domain.enums.HseSafetyInspectionReviewTypeEnum;
import org.dromara.safety.domain.enums.HseSafetyInspectionStatusEnum; import org.dromara.safety.domain.enums.HseSafetyInspectionStatusEnum;
import org.dromara.safety.domain.vo.violationrecord.HseViolationRecordVo; import org.dromara.safety.domain.vo.violationrecord.HseViolationRecordVo;
import org.dromara.safety.mapper.HseViolationRecordMapper; import org.dromara.safety.mapper.HseViolationRecordMapper;
@ -68,6 +71,9 @@ public class HseViolationRecordServiceImpl extends ServiceImpl<HseViolationRecor
@Resource @Resource
private IHseViolationLevelPostService violationLevelPostService; private IHseViolationLevelPostService violationLevelPostService;
@Resource
private IBusProjectTeamMemberService projectTeamMemberService;
@Resource @Resource
private SseProperties sseProperties; private SseProperties sseProperties;
@ -98,7 +104,18 @@ public class HseViolationRecordServiceImpl extends ServiceImpl<HseViolationRecor
*/ */
@Override @Override
public TableDataInfo<HseViolationRecordVo> queryPageList(HseViolationRecordQueryReq req, PageQuery pageQuery) { public TableDataInfo<HseViolationRecordVo> queryPageList(HseViolationRecordQueryReq req, PageQuery pageQuery) {
Page<HseViolationRecord> violationRecordPage = this.page(pageQuery.build(), this.buildQueryWrapper(req)); LambdaQueryWrapper<HseViolationRecord> lqw = this.buildQueryWrapper(req);
Long userId = LoginHelper.getUserId();
if (userId != null) {
BusProjectTeamMember one = projectTeamMemberService.lambdaQuery()
.eq(BusProjectTeamMember::getMemberId, userId)
.eq(BusProjectTeamMember::getPostId, "0")
.one();
if (one != null) {
lqw.eq(HseViolationRecord::getCorrectorId, userId);
}
}
Page<HseViolationRecord> violationRecordPage = this.page(pageQuery.build(), lqw);
return TableDataInfo.build(this.getVoPage(violationRecordPage)); return TableDataInfo.build(this.getVoPage(violationRecordPage));
} }
@ -247,8 +264,10 @@ public class HseViolationRecordServiceImpl extends ServiceImpl<HseViolationRecor
} }
if (req.getCorrectorId() != null) { if (req.getCorrectorId() != null) {
chatServerHandler.sendSystemMessageToUser(req.getCorrectorId(), chatServerHandler.sendSystemMessageToUser(req.getCorrectorId(),
"您有一份新的 AI 违章工单,请及时处理!工单号为:" + violationRecord.getId(),"2"); "您有一份新的 AI 违章工单,请及时处理!工单号为:" + violationRecord.getId(), "2");
} }
violationRecord.setStatus(HseSafetyInspectionStatusEnum.INFORM.getValue());
violationRecord.setReviewType(HseSafetyInspectionReviewTypeEnum.NOT_REVIEW.getValue());
boolean result = this.updateById(violationRecord); boolean result = this.updateById(violationRecord);
if (!result) { if (!result) {
throw new ServiceException("更新处理人操作失败", HttpStatus.ERROR); throw new ServiceException("更新处理人操作失败", HttpStatus.ERROR);
@ -317,8 +336,10 @@ public class HseViolationRecordServiceImpl extends ServiceImpl<HseViolationRecor
Long projectId = req.getProjectId(); Long projectId = req.getProjectId();
String violationType = req.getViolationType(); String violationType = req.getViolationType();
LocalDate violationTime = req.getViolationTime(); LocalDate violationTime = req.getViolationTime();
Long correctorId = req.getCorrectorId();
lqw.eq(ObjectUtils.isNotEmpty(projectId), HseViolationRecord::getProjectId, projectId); lqw.eq(ObjectUtils.isNotEmpty(projectId), HseViolationRecord::getProjectId, projectId);
lqw.eq(StringUtils.isNotBlank(violationType), HseViolationRecord::getViolationType, violationType); lqw.eq(StringUtils.isNotBlank(violationType), HseViolationRecord::getViolationType, violationType);
lqw.eq(ObjectUtils.isNotEmpty(correctorId), HseViolationRecord::getCorrectorId, correctorId);
if (violationTime != null) { if (violationTime != null) {
// 构造当天的起始和结束时间 // 构造当天的起始和结束时间
LocalDateTime startOfDay = violationTime.atStartOfDay(); LocalDateTime startOfDay = violationTime.atStartOfDay();
@ -404,6 +425,7 @@ public class HseViolationRecordServiceImpl extends ServiceImpl<HseViolationRecor
updateRecord.setId(id); updateRecord.setId(id);
updateRecord.setRectificationTime(new Date()); updateRecord.setRectificationTime(new Date());
updateRecord.setStatus(HseSafetyInspectionStatusEnum.RECTIFICATION.getValue()); updateRecord.setStatus(HseSafetyInspectionStatusEnum.RECTIFICATION.getValue());
updateRecord.setReviewType(HseSafetyInspectionReviewTypeEnum.NOT_REVIEW.getValue());
// 操作数据库 // 操作数据库
return this.updateById(updateRecord); return this.updateById(updateRecord);
} }

View File

@ -2,9 +2,9 @@ package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.dromara.common.tenant.core.TenantEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.dromara.common.tenant.core.TenantEntity;
/** /**
* OSS对象存储对象 * OSS对象存储对象
@ -37,6 +37,11 @@ public class SysOss extends TenantEntity {
*/ */
private String fileSuffix; private String fileSuffix;
/**
* 文件大小
*/
private Long fileSize;
/** /**
* URL地址 * URL地址
*/ */

View File

@ -42,6 +42,11 @@ public class SysOssVo implements Serializable {
*/ */
private String fileSuffix; private String fileSuffix;
/**
* 文件大小
*/
private Long fileSize;
/** /**
* URL地址 * URL地址
*/ */

View File

@ -146,4 +146,12 @@ public interface ISysOssService {
*/ */
String minioFileName(String prefix, MultipartFile file); String minioFileName(String prefix, MultipartFile file);
/**
* 格式化文件大小
*
* @param size 文件大小
* @return 文件大小
*/
String formatFileSize(Long size);
} }

View File

@ -24,7 +24,6 @@ import org.dromara.common.oss.core.OssClient;
import org.dromara.common.oss.entity.UploadResult; import org.dromara.common.oss.entity.UploadResult;
import org.dromara.common.oss.enumd.AccessPolicyType; import org.dromara.common.oss.enumd.AccessPolicyType;
import org.dromara.common.oss.factory.OssFactory; import org.dromara.common.oss.factory.OssFactory;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.domain.SysOss; import org.dromara.system.domain.SysOss;
import org.dromara.system.domain.bo.SysOssBo; import org.dromara.system.domain.bo.SysOssBo;
import org.dromara.system.domain.vo.SysOssUploadVo; import org.dromara.system.domain.vo.SysOssUploadVo;
@ -45,7 +44,6 @@ import java.net.URI;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
/** /**
@ -206,7 +204,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }
// 保存文件信息 // 保存文件信息
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult); return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), file.getSize(), uploadResult);
} }
@ -229,7 +227,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }
// 保存文件信息 // 保存文件信息
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult); return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), file.getSize(), uploadResult);
} }
/** /**
@ -340,7 +338,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }
// 保存文件信息 // 保存文件信息
return buildResultEntity(originalFileName, suffix, storage.getConfigKey(), uploadResult); return buildResultEntity(originalFileName, suffix, storage.getConfigKey(), length, uploadResult);
} }
/** /**
@ -387,18 +385,20 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
OssClient storage = OssFactory.instance(); OssClient storage = OssFactory.instance();
UploadResult uploadResult = storage.uploadSuffix(file, suffix); UploadResult uploadResult = storage.uploadSuffix(file, suffix);
long size = file.length(); // 单位:字节
// 保存文件信息 // 保存文件信息
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult); return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), size, uploadResult);
} }
@NotNull @NotNull
private SysOssVo buildResultEntity(String originalfileName, String suffix, String configKey, UploadResult uploadResult) { private SysOssVo buildResultEntity(String originalfileName, String suffix, String configKey, Long fileSize, UploadResult uploadResult) {
SysOss oss = new SysOss(); SysOss oss = new SysOss();
oss.setUrl(uploadResult.getUrl()); oss.setUrl(uploadResult.getUrl());
oss.setFileSuffix(suffix); oss.setFileSuffix(suffix);
oss.setFileName(uploadResult.getFilename()); oss.setFileName(uploadResult.getFilename());
oss.setOriginalName(originalfileName); oss.setOriginalName(originalfileName);
oss.setService(configKey); oss.setService(configKey);
oss.setFileSize(fileSize);
//罗成负责删掉 //罗成负责删掉
oss.setCreateBy(1L); oss.setCreateBy(1L);
@ -461,4 +461,26 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
OssClient storage = OssFactory.instance(); OssClient storage = OssFactory.instance();
return storage.getPath(prefix, suffix); return storage.getPath(prefix, suffix);
} }
/**
* 格式化文件大小
*
* @param size 文件大小
* @return 文件大小
*/
@Override
public String formatFileSize(Long size) {
if (size == null || size <= 0) {
return "0 B";
}
if (size < 1024) {
return size + " B";
} else if (size < 1024 * 1024) {
return String.format("%.2f KB", size / 1024.0);
} else if (size < 1024 * 1024 * 1024) {
return String.format("%.2f MB", size / 1024.0 / 1024.0);
} else {
return String.format("%.2f GB", size / 1024.0 / 1024.0 / 1024.0);
}
}
} }