Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@ -324,6 +324,7 @@ ys7:
|
||||
app-secret: 09e29c70ae1161fbc3ce2030fc09ba2e
|
||||
job:
|
||||
capture-enabled: false # 控制是否启用萤石抓拍任务
|
||||
device-sync-enabled: false # 控制是否同步萤石设备
|
||||
#ys7:
|
||||
# app-key: 081b0d6d5f7f4de8bc5c7fa350fb26ec
|
||||
# app-secret: caa37b9f60ef02deb57e563bc190e6db
|
||||
|
||||
@ -321,12 +321,13 @@ weather:
|
||||
api-host: n35rk53njv.re.qweatherapi.com
|
||||
# dxf转 geojson 执行文件名
|
||||
dxf2GeoJson:
|
||||
file-name: main.exe
|
||||
file-name: main
|
||||
ys7:
|
||||
app-key: 3acf9f1a43dc4209841e0893003db0a2
|
||||
app-secret: 09e29c70ae1161fbc3ce2030fc09ba2e
|
||||
job:
|
||||
capture-enabled: true # 控制是否启用萤石抓拍任务
|
||||
device-sync-enabled: true # 控制是否同步萤石设备
|
||||
# 斯巴达算法
|
||||
sparta:
|
||||
url: http://119.3.204.120:8040
|
||||
|
||||
@ -1517,6 +1517,7 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
lqw.eq(SubConstructionUser::getUserRole, "0");
|
||||
if (req.getProjectId() == null) {
|
||||
lqw.isNull(SubConstructionUser::getProjectId);
|
||||
lqw.apply("exists (select 1 from sys_user where user_id = sys_user_id and dept_id is null)");
|
||||
} else {
|
||||
lqw.eq(SubConstructionUser::getProjectId, req.getProjectId());
|
||||
}
|
||||
|
||||
@ -448,9 +448,9 @@ public class DesDrawingServiceImpl extends ServiceImpl<DesDrawingMapper, DesDraw
|
||||
try {
|
||||
ByteArrayOutputStream baos = PdfBoxQrCodeGenerator.addQRCodeToPDFOnAllPages(ossVo.getUrl(), bytes,isChangeFile);
|
||||
|
||||
try (FileOutputStream fileOut = new FileOutputStream("C:\\Users\\YuanJie\\Desktop\\test1.pdf")) {
|
||||
baos.writeTo(fileOut);
|
||||
}
|
||||
// try (FileOutputStream fileOut = new FileOutputStream("C:\\Users\\YuanJie\\Desktop\\test1.pdf")) {
|
||||
// baos.writeTo(fileOut);
|
||||
// }
|
||||
|
||||
FileNameMap fileNameMap = URLConnection.getFileNameMap();
|
||||
String originalName = ossVo.getOriginalName();
|
||||
|
||||
@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.manager.ys7manager.Ys7Manager;
|
||||
import org.dromara.manager.ys7manager.vo.Ys7QueryDeviceResponseVo;
|
||||
import org.dromara.other.service.IOthYs7DeviceService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -17,7 +18,8 @@ import java.util.List;
|
||||
* @date 2025/6/17 9:33
|
||||
*/
|
||||
@Slf4j
|
||||
//@Component
|
||||
@Component
|
||||
@ConditionalOnProperty(prefix = "ys7.job", name = "device-sync-enabled", havingValue = "true")
|
||||
public class IncSyncYs7DeviceData {
|
||||
|
||||
@Resource
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.materials.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -486,7 +487,10 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
|
||||
if (receive != null) {
|
||||
BeanUtils.copyProperties(receive, vo);
|
||||
}
|
||||
List<MatMaterialsNumberVo> numberVos = validMaterials.stream().map(m -> {
|
||||
|
||||
List<MatMaterialsNumberVo> numberVos = new ArrayList<>();
|
||||
|
||||
for (MatMaterials m : validMaterials) {
|
||||
MatMaterialsNumberVo numberVo = new MatMaterialsNumberVo();
|
||||
BeanUtils.copyProperties(m, numberVo);
|
||||
MatMaterialsInventory inv = inventoryMap.get(m.getId());
|
||||
@ -501,8 +505,10 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
|
||||
return outVo;
|
||||
}).toList());
|
||||
}
|
||||
return numberVo;
|
||||
}).toList();
|
||||
if(CollectionUtil.isNotEmpty(numberVo.getOutList())){
|
||||
numberVos.add(numberVo);
|
||||
}
|
||||
}
|
||||
vo.setMaterials(numberVos);
|
||||
resultList.add(vo);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.websocket.*;
|
||||
import jakarta.websocket.server.ServerEndpoint;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.project.service.IBusAttendanceMachineService;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -466,7 +467,8 @@ public class DeviceWebSocketServer {
|
||||
// 2. 发送请求
|
||||
boolean sendSuccess = sendMessageToDevice(sn, uuid, payload);
|
||||
if (!sendSuccess) {
|
||||
throw new Exception("发送请求失败,设备不在线或连接异常,SN: " + sn);
|
||||
log.error("发送请求失败,设备不在线或连接异常,SN: {}", sn);
|
||||
throw new ServiceException("发送请求失败,设备不在线或连接异常,SN: " + sn);
|
||||
}
|
||||
|
||||
// 3. 等待响应(10秒超时)
|
||||
@ -475,6 +477,7 @@ public class DeviceWebSocketServer {
|
||||
log.error("等待响应超时,SN: {},UUID: {}", sn, uuid);
|
||||
responseChannels.remove(uuid);
|
||||
snToUuids.get(sn).remove(uuid);
|
||||
log.error("等待响应超时(10秒),SN: {}", sn, e);
|
||||
throw new Exception("等待响应超时(10秒),SN: " + sn, e);
|
||||
} finally {
|
||||
// 4. 清理响应通道(防止内存泄漏)
|
||||
|
||||
@ -79,6 +79,15 @@ public class PgsProgressCategoryController extends BaseController {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据进度父级查询进度类别列表已完成产值
|
||||
*/
|
||||
@SaCheckPermission("progress:progressCategory:listByParent")
|
||||
@GetMapping("/getValueByParentId")
|
||||
public R<PgsProgressCategoryValueVo> getValueByParentId(PgsProgressCategoryQueryByParentReq req) {
|
||||
return R.ok(pgsProgressCategoryService.getValueByParentId(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目获取进度类别模版顶级目录列表
|
||||
*/
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package org.dromara.progress.domain.vo.progresscategory;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
* @date 2025-10-16 11:41
|
||||
*/
|
||||
@Data
|
||||
public class PgsProgressCategoryValueVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -7985655623513612674L;
|
||||
|
||||
/**
|
||||
* 产值金额(业主)
|
||||
*/
|
||||
private BigDecimal ownerValue;
|
||||
|
||||
/**
|
||||
* 产值金额(分包)
|
||||
*/
|
||||
private BigDecimal constructionValue;
|
||||
}
|
||||
@ -155,7 +155,12 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
*/
|
||||
List<Map<String, Object>> getMatrixIdAndNumber(Long projectId);
|
||||
|
||||
|
||||
/**
|
||||
* 转换进度类别vo为进度类别实体
|
||||
*
|
||||
* @param vo 进度类别vo
|
||||
* @return 进度类别实体
|
||||
*/
|
||||
PgsProgressCategory convertVoToEntity(PgsProgressCategoryVo vo);
|
||||
|
||||
/**
|
||||
@ -246,4 +251,12 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
* @return 进度类别甘特图结构
|
||||
*/
|
||||
List<PgsProgressCategoryGanttSubProjectVo> getGanttStructureList(Long progressCategoryId);
|
||||
|
||||
/**
|
||||
* 获取进度类别产值
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @return 进度类别产值
|
||||
*/
|
||||
PgsProgressCategoryValueVo getValueByParentId(PgsProgressCategoryQueryByParentReq req);
|
||||
}
|
||||
|
||||
@ -2126,6 +2126,60 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度类别产值
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @return 进度类别产值
|
||||
*/
|
||||
@Override
|
||||
public PgsProgressCategoryValueVo getValueByParentId(PgsProgressCategoryQueryByParentReq req) {
|
||||
PgsProgressCategoryValueVo vo = new PgsProgressCategoryValueVo();
|
||||
vo.setOwnerValue(BigDecimal.ZERO);
|
||||
vo.setConstructionValue(BigDecimal.ZERO);
|
||||
// 根据查询条件获取数据
|
||||
Long parentId = req.getParentId();
|
||||
String name = req.getName();
|
||||
if (parentId == null) {
|
||||
return vo;
|
||||
}
|
||||
QueryWrapper<PgsProgressCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.apply("FIND_IN_SET({0}, ancestors)", parentId);
|
||||
queryWrapper.like(StringUtils.isNotBlank(name), "name", name);
|
||||
List<PgsProgressCategory> progressCategoryList = this.list(queryWrapper);
|
||||
if (CollUtil.isEmpty(progressCategoryList)) {
|
||||
return vo;
|
||||
}
|
||||
// 过滤掉那些还有子节点的,只保留最底层
|
||||
Set<Long> parentIds = progressCategoryList.stream()
|
||||
.map(PgsProgressCategory::getParentId)
|
||||
.collect(Collectors.toSet());
|
||||
List<PgsProgressCategory> categoryList = progressCategoryList.stream()
|
||||
.filter(item -> !parentIds.contains(item.getId())) // 没有被当作别人父id的,就是叶子节点
|
||||
.toList();
|
||||
// 统计完成产值
|
||||
BigDecimal ownerValue = categoryList.stream().map(item -> {
|
||||
BigDecimal completed = item.getCompleted();
|
||||
BigDecimal ownerPrice = item.getOwnerPrice();
|
||||
if (item.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
||||
completed = completed.multiply(item.getTotal()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return completed.multiply(ownerPrice);
|
||||
}).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_UP);
|
||||
vo.setOwnerValue(ownerValue);
|
||||
// 统计施工产值
|
||||
BigDecimal constructionValue = categoryList.stream().map(item -> {
|
||||
BigDecimal completed = item.getCompleted();
|
||||
BigDecimal constructionPrice = item.getConstructionPrice();
|
||||
if (item.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
||||
completed = completed.multiply(item.getTotal()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return completed.multiply(constructionPrice);
|
||||
}).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_UP);
|
||||
vo.setConstructionValue(constructionValue);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算进度类别(含子类别)的开始和结束时间。
|
||||
* <p>
|
||||
|
||||
@ -105,4 +105,10 @@ public class BusWorkWageController extends BaseController {
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(busWorkWageService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
@GetMapping("/allList")
|
||||
public R<List<BusWorkWageVo>> list(BusWorkWageQueryReq req) {
|
||||
return R.ok(busWorkWageService.queryList(req));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package org.dromara.project.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目与部门关联对象 bus_project_dept
|
||||
*
|
||||
* @author lilemy
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@TableName("bus_project_dept")
|
||||
public class BusProjectDept {
|
||||
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
@ -134,4 +135,9 @@ public class BusProjectCreateReq implements Serializable {
|
||||
* 位置信息
|
||||
*/
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 所属部门列表
|
||||
*/
|
||||
private List<Long> deptIds;
|
||||
}
|
||||
|
||||
@ -69,4 +69,9 @@ public class BusProjectQueryReq implements Serializable {
|
||||
* 显示隐藏(0显示 1隐藏)
|
||||
*/
|
||||
private String showHidden;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long deptId;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.domain.bo.Punchrange;
|
||||
import org.dromara.system.domain.vo.SysDeptVo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@ -212,4 +213,9 @@ public class BusProjectVo implements Serializable {
|
||||
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private List<SysDeptVo> deptList;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package org.dromara.project.mapper;
|
||||
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.project.domain.BusProjectDept;
|
||||
|
||||
/**
|
||||
* 项目与部门关联Mapper接口
|
||||
*
|
||||
* @author lilemy
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
public interface BusProjectDeptMapper extends BaseMapperPlus<BusProjectDept, BusProjectDept> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package org.dromara.project.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.project.domain.BusProjectDept;
|
||||
|
||||
/**
|
||||
* 项目与部门关联Service接口
|
||||
*
|
||||
* @author lilemy
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
public interface IBusProjectDeptService extends IService<BusProjectDept> {
|
||||
}
|
||||
@ -2,6 +2,7 @@ package org.dromara.project.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@ -19,12 +20,11 @@ import org.dromara.project.domain.vo.projectteammember.BusProjectTeamMemberVo;
|
||||
import org.dromara.project.service.IBusAttendanceMachineService;
|
||||
import org.dromara.project.service.IBusAttendanceMachineUserService;
|
||||
import org.dromara.project.service.IBusProjectTeamMemberService;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -33,6 +33,7 @@ import java.util.stream.Collectors;
|
||||
* @author lilemy
|
||||
* @date 2025-10-15
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BusAttendanceMachineUserServiceImpl implements IBusAttendanceMachineUserService {
|
||||
@ -45,6 +46,8 @@ public class BusAttendanceMachineUserServiceImpl implements IBusAttendanceMachin
|
||||
|
||||
private final IBusProjectTeamMemberService projectTeamMemberService;
|
||||
|
||||
private final ISysOssService ossService;
|
||||
|
||||
/**
|
||||
* 查询符合条件的考勤机用户列表
|
||||
*
|
||||
@ -74,18 +77,20 @@ public class BusAttendanceMachineUserServiceImpl implements IBusAttendanceMachin
|
||||
throw new ServiceException("所选班组与考勤机不匹配", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 获取考勤机里的用户
|
||||
Set<Long> userIdList = new HashSet<>();
|
||||
Set<String> userIdList = new HashSet<>();
|
||||
try {
|
||||
KqjEntity.CommonResponse response = deviceMessageSender.getAllUsers(machine.getSn());
|
||||
int code = response.getData().getCode();
|
||||
if (code == 0 || code == 200) {
|
||||
log.info("获取考勤机数据成功:{}", response.getData());
|
||||
String[] userIds = response.getData().getUserIds();
|
||||
userIdList = Arrays.stream(userIds).map(Long::parseLong).collect(Collectors.toSet());
|
||||
userIdList = Arrays.stream(userIds).collect(Collectors.toSet());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取考勤机用户失败,sn:{}", machine.getSn(), e);
|
||||
throw new ServiceException("获取考勤机用户失败", HttpStatus.ERROR);
|
||||
}
|
||||
Set<Long> finalUserIdList = userIdList;
|
||||
Set<String> finalUserIdList = userIdList;
|
||||
return teamMemberList.stream().map(member -> {
|
||||
BusAttendanceMachineUserVo vo = new BusAttendanceMachineUserVo();
|
||||
vo.setMachineId(req.getMachineId());
|
||||
@ -94,7 +99,7 @@ public class BusAttendanceMachineUserServiceImpl implements IBusAttendanceMachin
|
||||
vo.setUserName(member.getMemberName());
|
||||
if (CollUtil.isEmpty(finalUserIdList)) {
|
||||
vo.setIdentifying(0);
|
||||
} else if (finalUserIdList.contains(member.getMemberId())) {
|
||||
} else if (finalUserIdList.contains(member.getMemberId().toString())) {
|
||||
vo.setIdentifying(1);
|
||||
} else {
|
||||
vo.setIdentifying(0);
|
||||
@ -120,13 +125,31 @@ public class BusAttendanceMachineUserServiceImpl implements IBusAttendanceMachin
|
||||
List<SubConstructionUser> userList = constructionUserService.lambdaQuery()
|
||||
.in(SubConstructionUser::getSysUserId, userIds)
|
||||
.list();
|
||||
// 获取用户人脸照信息
|
||||
List<Long> faceIds = userList.stream().map(SubConstructionUser::getFacePic).map(Long::parseLong).distinct().toList();
|
||||
List<SysOssVo> ossVos = ossService.listByIds(faceIds);
|
||||
Map<Long, SysOssVo> ossVoMap = ossVos.stream()
|
||||
.collect(Collectors.toMap(SysOssVo::getOssId, v -> v));
|
||||
// 返回数据
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("用户:[");
|
||||
int count = 0;
|
||||
for (SubConstructionUser user : userList) {
|
||||
String facePic = user.getFacePic();
|
||||
if (StringUtils.isBlank(facePic)) {
|
||||
sb.append(user.getUserName()).append(" ");
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
SysOssVo ossVo = ossVoMap.get(Long.parseLong(facePic));
|
||||
if (ossVo == null) {
|
||||
sb.append(user.getUserName()).append(" ");
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
Boolean result = deviceMessageSender.sendPersonnelInformation(machine.getSn(),
|
||||
user.getSysUserId().toString(), user.getUserName(), user.getFacePic());
|
||||
user.getSysUserId().toString(), user.getUserName(), ossVo.getUrl());
|
||||
log.info("考勤机 Sn:{} ,用户:{} 下发成功", machine.getSn(), user.getUserName());
|
||||
if (!result) {
|
||||
sb.append(user.getUserName()).append(" ");
|
||||
count++;
|
||||
|
||||
@ -119,7 +119,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
// 出勤状态(正常、迟到、早退)
|
||||
private static final Set<String> ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(BusAttendanceClockStatusEnum.NORMAL.getValue(),
|
||||
BusAttendanceClockStatusEnum.LATE.getValue(), BusAttendanceClockStatusEnum.LEAVEEARLY.getValue()
|
||||
,BusAttendanceClockStatusEnum.REISSUE.getValue()));
|
||||
, BusAttendanceClockStatusEnum.REISSUE.getValue()));
|
||||
|
||||
|
||||
/**
|
||||
@ -320,7 +320,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
// 获取当前用户
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Long replaceId = null;
|
||||
if(req.getUserId()!=null){
|
||||
if (req.getUserId() != null) {
|
||||
userId = req.getUserId();
|
||||
replaceId = LoginHelper.getUserId();
|
||||
}
|
||||
@ -342,10 +342,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
throw new ServiceException("当前用户已被禁止打卡", HttpStatus.ERROR);
|
||||
}
|
||||
//施工人员需要判断工资
|
||||
if("0".equals(constructionUser.getUserRole())){
|
||||
if ("0".equals(constructionUser.getUserRole())) {
|
||||
String typeOfWork = constructionUser.getTypeOfWork();
|
||||
BusWorkWage workWageByWorkType = workWageService.getWorkWageByWorkType(typeOfWork);
|
||||
if(constructionUser.getSalary().compareTo(BigDecimal.ZERO)==0 && workWageByWorkType == null){
|
||||
if (constructionUser.getSalary().compareTo(BigDecimal.ZERO) == 0 && workWageByWorkType == null) {
|
||||
throw new ServiceException("当前用户没有设置工资,禁止打卡", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
@ -402,7 +402,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
}
|
||||
//只要请假,直接归为请假
|
||||
LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
if(leaveService.isLeave(localDateTime,userId)){
|
||||
if (leaveService.isLeave(localDateTime, userId)) {
|
||||
attendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
}
|
||||
|
||||
@ -418,7 +418,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
attendance.setLng(req.getLng());
|
||||
try {
|
||||
attendance.setClockLocation(JSTUtil.getLocationName(req.getLat(), req.getLng()));
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error("获取打卡位置失败", e);
|
||||
}
|
||||
|
||||
@ -456,7 +456,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
}
|
||||
//只要请假,直接归为请假
|
||||
LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
if(leaveService.isLeave(localDateTime,userId)){
|
||||
if (leaveService.isLeave(localDateTime, userId)) {
|
||||
busAttendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
}
|
||||
updateById(busAttendance);
|
||||
@ -474,7 +474,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
}
|
||||
//只要请假,直接归为请假
|
||||
LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
if(leaveService.isLeave(localDateTime,userId)){
|
||||
if (leaveService.isLeave(localDateTime, userId)) {
|
||||
attendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
}
|
||||
// 填充信息
|
||||
@ -489,7 +489,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
attendance.setLng(req.getLng());
|
||||
try {
|
||||
attendance.setClockLocation(JSTUtil.getLocationName(req.getLat(), req.getLng()));
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error("获取打卡位置失败", e);
|
||||
}
|
||||
// 上传人脸照
|
||||
@ -676,7 +676,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
|
||||
|
||||
@Override
|
||||
public List<BusAttendanceVo> getTodayAttendance(Long projectId,Long userId) {
|
||||
public List<BusAttendanceVo> getTodayAttendance(Long projectId, Long userId) {
|
||||
|
||||
if (userId == null) {
|
||||
userId = LoginHelper.getUserId();
|
||||
@ -915,8 +915,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
if ("2".equals(appUserType)) {
|
||||
List<BusProjectTeamAppVo> byUserId = projectTeamService.getByUserId(userId, dto.getProjectId());
|
||||
|
||||
if(CollectionUtil.isEmpty(byUserId)){
|
||||
return new AttendanceCountVo(0,0);
|
||||
if (CollectionUtil.isEmpty(byUserId)) {
|
||||
return new AttendanceCountVo(0, 0);
|
||||
}
|
||||
list2 = byUserId.stream().map(BusProjectTeamAppVo::getId).toList();
|
||||
}
|
||||
@ -962,7 +962,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
if ("2".equals(appUserType)) {
|
||||
List<BusProjectTeamAppVo> byUserId = projectTeamService.getByUserId(userId, dto.getProjectId());
|
||||
|
||||
if(CollectionUtil.isEmpty(byUserId)){
|
||||
if (CollectionUtil.isEmpty(byUserId)) {
|
||||
return TableDataInfo.build(new ArrayList<>());
|
||||
}
|
||||
list1 = byUserId.stream().map(BusProjectTeamAppVo::getId).toList();
|
||||
@ -1192,10 +1192,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
|
||||
List<Long> allUserIds = constructionUserService.list(Wrappers.<SubConstructionUser>lambdaQuery()
|
||||
.eq(SubConstructionUser::getUserRole, "0")
|
||||
.eq(SubConstructionUser::getProjectId,dto.getProjectId())
|
||||
.eq(dto.getTeamId()!=null,SubConstructionUser::getTeamId,dto.getTeamId())
|
||||
.eq(StrUtil.isNotBlank(dto.getTypeOfWork()),SubConstructionUser::getTypeOfWork,dto.getTypeOfWork())
|
||||
.like(StrUtil.isNotBlank(dto.getUserName()),SubConstructionUser::getUserName,dto.getUserName())
|
||||
.eq(SubConstructionUser::getProjectId, dto.getProjectId())
|
||||
.eq(dto.getTeamId() != null, SubConstructionUser::getTeamId, dto.getTeamId())
|
||||
.eq(StrUtil.isNotBlank(dto.getTypeOfWork()), SubConstructionUser::getTypeOfWork, dto.getTypeOfWork())
|
||||
.like(StrUtil.isNotBlank(dto.getUserName()), SubConstructionUser::getUserName, dto.getUserName())
|
||||
.isNotNull(SubConstructionUser::getTeamId)
|
||||
).stream().map(SubConstructionUser::getSysUserId).toList();
|
||||
|
||||
@ -1203,9 +1203,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
// 往前14天,包含今天
|
||||
LocalDate startDate = now.minusDays(13);
|
||||
List<BusAttendance> list;
|
||||
if(CollectionUtil.isEmpty(allUserIds)){
|
||||
if (CollectionUtil.isEmpty(allUserIds)) {
|
||||
list = new ArrayList<>();
|
||||
}else {
|
||||
} else {
|
||||
list = list(Wrappers.<BusAttendance>lambdaQuery()
|
||||
.in(BusAttendance::getUserId, allUserIds)
|
||||
.between(BusAttendance::getClockDate, startDate, now)
|
||||
@ -1255,6 +1255,21 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
vo.setAttendance(full);
|
||||
vo.setHalfAttendance(half);
|
||||
vo.setAbsenteeism(absent);
|
||||
|
||||
String todayStr = currentDate.format(DateTimeFormatter.ISO_LOCAL_DATE); // 结果:"2024-10-10"
|
||||
|
||||
int count = 0;
|
||||
if (CollectionUtil.isNotEmpty(allUserIds)) {
|
||||
count = (int) leaveService.count(Wrappers.<BusLeave>lambdaQuery()
|
||||
.eq(BusLeave::getProjectId, dto.getProjectId())
|
||||
.in(BusLeave::getUserId, allUserIds)
|
||||
.eq(dto.getTeamId() != null, BusLeave::getTeamId, dto.getTeamId())
|
||||
// 关键:给日期字符串加单引号,避免 SQL 语法错误
|
||||
.apply("DATE(start_time) <= {0}", todayStr)
|
||||
.apply("DATE(end_time) >= {0}", todayStr)
|
||||
);
|
||||
}
|
||||
vo.setLeave(count);
|
||||
result.add(vo);
|
||||
currentDate = currentDate.plusDays(1);
|
||||
}
|
||||
@ -1276,10 +1291,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
|
||||
List<Long> allUserIds = constructionUserService.list(Wrappers.<SubConstructionUser>lambdaQuery()
|
||||
.eq(SubConstructionUser::getUserRole, "0")
|
||||
.eq(SubConstructionUser::getProjectId,dto.getProjectId())
|
||||
.eq(dto.getTeamId()!=null,SubConstructionUser::getTeamId,dto.getTeamId())
|
||||
.eq(StrUtil.isNotBlank(dto.getTypeOfWork()),SubConstructionUser::getTypeOfWork,dto.getTypeOfWork())
|
||||
.like(StrUtil.isNotBlank(dto.getUserName()),SubConstructionUser::getUserName,dto.getUserName())
|
||||
.eq(SubConstructionUser::getProjectId, dto.getProjectId())
|
||||
.eq(dto.getTeamId() != null, SubConstructionUser::getTeamId, dto.getTeamId())
|
||||
.eq(StrUtil.isNotBlank(dto.getTypeOfWork()), SubConstructionUser::getTypeOfWork, dto.getTypeOfWork())
|
||||
.like(StrUtil.isNotBlank(dto.getUserName()), SubConstructionUser::getUserName, dto.getUserName())
|
||||
.isNotNull(SubConstructionUser::getTeamId)
|
||||
).stream().map(SubConstructionUser::getSysUserId).toList();
|
||||
|
||||
@ -1287,19 +1302,24 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
String todayStr = now.format(DateTimeFormatter.ISO_LOCAL_DATE); // 结果:"2024-10-10"
|
||||
|
||||
// 2. 拼接 SQL 时添加单引号,确保语法正确
|
||||
int count = (int)leaveService.count(Wrappers.<BusLeave>lambdaQuery()
|
||||
.eq(BusLeave::getTimeType, "2")
|
||||
// 关键:给日期字符串加单引号,避免 SQL 语法错误
|
||||
.apply("DATE(start_time) <= {0}", todayStr)
|
||||
.apply("DATE(end_time) >= {0}", todayStr)
|
||||
);
|
||||
int count = 0;
|
||||
if (CollectionUtil.isNotEmpty(allUserIds)) {
|
||||
count = (int) leaveService.count(Wrappers.<BusLeave>lambdaQuery()
|
||||
.eq(BusLeave::getProjectId, dto.getProjectId())
|
||||
.in(BusLeave::getUserId, allUserIds)
|
||||
.eq(dto.getTeamId() != null, BusLeave::getTeamId, allUserIds)
|
||||
// 关键:给日期字符串加单引号,避免 SQL 语法错误
|
||||
.apply("DATE(start_time) <= {0}", todayStr)
|
||||
.apply("DATE(end_time) >= {0}", todayStr)
|
||||
);
|
||||
}
|
||||
|
||||
List<BusAttendance> list;
|
||||
if(CollectionUtil.isEmpty(allUserIds)){
|
||||
if (CollectionUtil.isEmpty(allUserIds)) {
|
||||
list = new ArrayList<>();
|
||||
}else {
|
||||
} else {
|
||||
list = list(Wrappers.<BusAttendance>lambdaQuery()
|
||||
.in(CollectionUtil.isNotEmpty(allUserIds),BusAttendance::getUserId, allUserIds)
|
||||
.in(CollectionUtil.isNotEmpty(allUserIds), BusAttendance::getUserId, allUserIds)
|
||||
.eq(BusAttendance::getClockDate, now)
|
||||
.orderByAsc(BusAttendance::getClockDate)
|
||||
);
|
||||
@ -1332,10 +1352,11 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
vo.setHalfAttendance(half);
|
||||
vo.setAbsenteeism(absent);
|
||||
//计算考勤率
|
||||
vo.setAllUserNum(allUserIds.size()- count);
|
||||
vo.setClockNum(full+half);
|
||||
vo.setAttendanceRate(BigDecimalUtil.toPercentage(new BigDecimal(full+half),
|
||||
new BigDecimal(vo.getAllUserNum())));
|
||||
vo.setAllUserNum(allUserIds.size() - count);
|
||||
vo.setLeave(count);
|
||||
vo.setClockNum(full + half);
|
||||
vo.setAttendanceRate(BigDecimalUtil.toPercentage(new BigDecimal(full + half),
|
||||
new BigDecimal(vo.getAllUserNum())));
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package org.dromara.project.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.project.domain.BusProjectDept;
|
||||
import org.dromara.project.mapper.BusProjectDeptMapper;
|
||||
import org.dromara.project.service.IBusProjectDeptService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 项目与部门关联Service业务层处理
|
||||
*
|
||||
* @author lilemy
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BusProjectDeptServiceImpl extends ServiceImpl<BusProjectDeptMapper, BusProjectDept>
|
||||
implements IBusProjectDeptService {
|
||||
}
|
||||
@ -3,6 +3,7 @@ package org.dromara.project.service.impl;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@ -56,7 +57,9 @@ import org.dromara.project.mapper.BusProjectMapper;
|
||||
import org.dromara.project.service.*;
|
||||
import org.dromara.quality.service.IQltKnowledgeDocumentService;
|
||||
import org.dromara.safety.service.IHseKnowledgeDocumentService;
|
||||
import org.dromara.system.domain.vo.SysDeptVo;
|
||||
import org.dromara.system.domain.vo.SysDictDataVo;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.dromara.system.service.ISysDictDataService;
|
||||
import org.dromara.workflow.service.IFlwDefinitionService;
|
||||
import org.dromara.xzd.utilS.IdWorker;
|
||||
@ -147,6 +150,13 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
@Resource
|
||||
private ISysDictDataService dictDataService;
|
||||
|
||||
@Resource
|
||||
private IBusProjectDeptService projectDeptService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private ISubConstructionUserService constructionUserService;
|
||||
@ -402,6 +412,20 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
if (!saveRelevancy) {
|
||||
throw new ServiceException("新增用户与项目关联失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 保存项目与部门的关联
|
||||
List<Long> deptIds = req.getDeptIds();
|
||||
if (CollUtil.isNotEmpty(deptIds)) {
|
||||
List<BusProjectDept> projectDeptList = deptIds.stream().map(deptId -> {
|
||||
BusProjectDept projectDept = new BusProjectDept();
|
||||
projectDept.setDeptId(deptId);
|
||||
projectDept.setProjectId(projectId);
|
||||
return projectDept;
|
||||
}).toList();
|
||||
boolean saveBatch = projectDeptService.saveBatch(projectDeptList);
|
||||
if (!saveBatch) {
|
||||
throw new ServiceException("保存项目与部门的关联失败", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
// 异步执行数据同步
|
||||
self.insertProjectSyncThing(projectId)
|
||||
.thenAccept(result -> log.info("项目[{}-{}]异步执行数据同步成功", req.getProjectName(), projectId))
|
||||
@ -694,6 +718,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
String principal = req.getPrincipal();
|
||||
String principalPhone = req.getPrincipalPhone();
|
||||
String showHidden = req.getShowHidden();
|
||||
Long deptId = req.getDeptId();
|
||||
// 模糊查询
|
||||
lqw.like(StringUtils.isNotBlank(projectName), BusProject::getProjectName, projectName);
|
||||
lqw.like(StringUtils.isNotBlank(shortName), BusProject::getShortName, shortName);
|
||||
@ -713,6 +738,18 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
final Long PID = 0L;
|
||||
lqw.eq(BusProject::getPId, PID);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(deptId)) {
|
||||
SysDeptVo sysDeptVo = deptService.selectDeptById(deptId);
|
||||
List<Long> list = StringUtils.splitTo(sysDeptVo.getAncestors(), Convert::toLong);
|
||||
List<Long> projectDepts = new ArrayList<>();
|
||||
if (list.size() >= 2) {
|
||||
projectDepts = projectDeptService.lambdaQuery()
|
||||
.eq(BusProjectDept::getDeptId, list.get(1))
|
||||
.list()
|
||||
.stream().map(BusProjectDept::getProjectId).toList();
|
||||
}
|
||||
lqw.in(CollUtil.isNotEmpty(projectDepts), BusProject::getId, projectDepts);
|
||||
}
|
||||
// 排序
|
||||
lqw.orderByAsc(BusProject::getSort);
|
||||
return lqw;
|
||||
@ -1186,7 +1223,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
Map<String, String> map2 = new HashMap<>();
|
||||
map2.put("lng", project.getLng());
|
||||
map2.put("lat", project.getLat());
|
||||
map2.put("position",project.getPosition());
|
||||
map2.put("position", project.getPosition());
|
||||
map2.put("projectId", project.getId().toString());
|
||||
map1.put(project.getProjectName(), map2);
|
||||
//当满足条件时删除该元素
|
||||
@ -1248,7 +1285,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
if (dto.getProjectId() == null || dto.getPosition() == null) {
|
||||
throw new ServiceException("传递参数不能为空!");
|
||||
}
|
||||
return baseMapper.update(new LambdaUpdateWrapper<BusProject>().set(BusProject::getPosition, dto.getPosition()).eq(BusProject::getId, dto.getProjectId())) >0;
|
||||
return baseMapper.update(new LambdaUpdateWrapper<BusProject>().set(BusProject::getPosition, dto.getPosition()).eq(BusProject::getId, dto.getProjectId())) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,172 @@
|
||||
package org.dromara.quality.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.quality.domain.QltFileFolder;
|
||||
|
||||
import org.dromara.quality.domain.dto.fileFolder.QltFileFolderCreateDTO;
|
||||
import org.dromara.quality.domain.dto.fileFolder.QltFileFolderMoveDTO;
|
||||
import org.dromara.quality.domain.dto.fileFolder.QltListQueryDto;
|
||||
import org.dromara.quality.domain.vo.QltFileFolderVo;
|
||||
|
||||
import org.dromara.quality.domain.vo.fileFolder.QltFileFolderTreeVO;
|
||||
import org.dromara.quality.service.IQltFileFolderService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.core.domain.R;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 质量会议纪要
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/quality/fileFolder")
|
||||
public class QltFileFolderController extends BaseController {
|
||||
|
||||
private final IQltFileFolderService qltFileFolderService;
|
||||
|
||||
/**
|
||||
* 查询会议纪要列表
|
||||
*/
|
||||
@SaCheckPermission("quality:fileFolder:listAll")
|
||||
@GetMapping("/list-all")
|
||||
public R<List<QltFileFolderVo>> listAll(QltListQueryDto dto) {
|
||||
return R.ok(qltFileFolderService.listAll(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定目录的树形结构(一次性加载所有层级)
|
||||
* @return 树形结构列表
|
||||
*/
|
||||
@GetMapping("/tree-all")
|
||||
public R<List<QltFileFolderTreeVO>> treeAll(QltListQueryDto dto) {
|
||||
|
||||
// 1. 查询所有子项(利用path前缀匹配,一次性加载所有层级)
|
||||
List<QltFileFolder> allItems = qltFileFolderService.list(new LambdaQueryWrapper<QltFileFolder>()
|
||||
.eq(QltFileFolder::getProjectId, dto.getProjectId())
|
||||
.like(QltFileFolder::getPath, "," + dto.getParentId() + ",") // 包含父ID的所有子项
|
||||
.eq(dto.getType()!=null,QltFileFolder::getType, dto.getType())
|
||||
.orderByDesc(QltFileFolder::getId)
|
||||
.orderByAsc(QltFileFolder::getSort)
|
||||
);
|
||||
|
||||
// 2. 构建树形结构
|
||||
List<QltFileFolderTreeVO> treeVOS = buildTree(allItems, dto.getParentId());
|
||||
return R.ok(treeVOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建树形结构
|
||||
*/
|
||||
private List<QltFileFolderTreeVO> buildTree(List<QltFileFolder> allItems, Long parentId) {
|
||||
return allItems.stream()
|
||||
.filter(item -> parentId.equals(item.getParentId()))
|
||||
.map(item -> {
|
||||
QltFileFolderTreeVO vo = new QltFileFolderTreeVO();
|
||||
// 复制基本属性(可使用BeanUtils.copyProperties)
|
||||
vo.setId(item.getId());
|
||||
vo.setName(item.getName());
|
||||
vo.setParentId(item.getParentId());
|
||||
vo.setType(item.getType());
|
||||
vo.setLevel(item.getLevel());
|
||||
vo.setSort(item.getSort());
|
||||
vo.setFileSuffix(item.getFileSuffix());
|
||||
|
||||
// 递归查询子节点
|
||||
vo.setChildren(buildTree(allItems, item.getId()));
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件或文件夹
|
||||
*/
|
||||
@SaCheckPermission("quality:fileFolder:create")
|
||||
@PostMapping("/create")
|
||||
public R<QltFileFolder> create(@RequestBody QltFileFolderCreateDTO dto) {
|
||||
return R.ok(qltFileFolderService.createFileOrFolder(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件或文件夹(级联删除子项)
|
||||
*/
|
||||
@SaCheckPermission("quality:fileFolder:delete")
|
||||
@DeleteMapping("/{ids}")
|
||||
@Transactional
|
||||
public R<Boolean> delete(@PathVariable List<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
qltFileFolderService.deleteFileOrFolder(id);
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动文件或文件夹到指定目录
|
||||
*/
|
||||
@SaCheckPermission("quality:fileFolder:move")
|
||||
@PostMapping("/move")
|
||||
@Transactional
|
||||
public R<Boolean> move(@RequestBody QltFileFolderMoveDTO dto) {
|
||||
return R.ok(qltFileFolderService.moveFileOrFolder(dto.getId(), dto.getTargetParentId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传ZIP文件并自动解压到指定目录(支持多层级)
|
||||
*/
|
||||
@SaCheckPermission("quality:fileFolder:create")
|
||||
@PostMapping("/uploadAndUnzip")
|
||||
public R<String> uploadAndUnzip(
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("parentId") Long parentId,
|
||||
@RequestParam("projectId") Long projectId) {
|
||||
|
||||
try {
|
||||
// 实际应用中,userId和deptId通常从登录信息中获取
|
||||
String result = qltFileFolderService.uploadAndUnzip(file, parentId, projectId);
|
||||
return R.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return R.fail(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return R.fail("文件处理失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/unzip")
|
||||
public R<String> unzip(@RequestParam("id") Long id,
|
||||
@RequestParam("parentId") Long parentId) {
|
||||
return R.ok(qltFileFolderService.unzip(id, parentId));
|
||||
}
|
||||
|
||||
|
||||
@SaCheckPermission("quality:fileFolder:reName")
|
||||
@PutMapping("/reName")
|
||||
public R<Boolean> reName(@RequestParam("id") Long id,
|
||||
@RequestParam("name") String name) {
|
||||
return R.ok(qltFileFolderService.reName(id,name));
|
||||
}
|
||||
|
||||
|
||||
@SaCheckPermission("quality:fileFolder:download")
|
||||
@GetMapping("/download/{id}")
|
||||
public void download(@PathVariable Long id, HttpServletResponse response) throws IOException {
|
||||
qltFileFolderService.download(id, response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package org.dromara.quality.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 质量会议纪要对象 qlt_file_folder
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("qlt_file_folder")
|
||||
public class QltFileFolder extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 名称(文件名或文件夹名)
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父级ID(0表示根目录)
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 类型(1-文件夹,2-文件)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 层级(根目录为1,子级+1)
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 同层级排序号
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 层级路径(如:1,2,3 表示ID为1→2→3的层级)
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package org.dromara.quality.domain.bo;
|
||||
|
||||
import org.dromara.quality.domain.QltFileFolder;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 质量会议纪要业务对象 qlt_file_folder
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = QltFileFolder.class, reverseConvertGenerate = false)
|
||||
public class QltFileFolderBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 名称(文件名或文件夹名)
|
||||
*/
|
||||
@NotBlank(message = "名称(文件名或文件夹名)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父级ID(0表示根目录)
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 类型(1-文件夹,2-文件)
|
||||
*/
|
||||
@NotNull(message = "类型(1-文件夹,2-文件)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 层级(根目录为1,子级+1)
|
||||
*/
|
||||
@NotNull(message = "层级(根目录为1,子级+1)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 同层级排序号
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 层级路径(如:1,2,3 表示ID为1→2→3的层级)
|
||||
*/
|
||||
@NotBlank(message = "层级路径(如:1,2,3 表示ID为1→2→3的层级)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package org.dromara.quality.domain.dto.fileFolder;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class QltFileFolderCreateDTO {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 父级ID(0表示根目录)
|
||||
*/
|
||||
private Long parentId = 0L;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
@NotNull(message = "类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer sort=0;
|
||||
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* 文件存储路径(仅文件有效)
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package org.dromara.quality.domain.dto.fileFolder;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QltFileFolderMoveDTO {
|
||||
|
||||
@NotNull(message = "文件/文件夹ID不能为空")
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "目标父目录ID不能为空")
|
||||
private Long targetParentId;
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
package org.dromara.safety.domain.dto.fileFolder;
|
||||
package org.dromara.quality.domain.dto.fileFolder;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ListQueryDto {
|
||||
public class QltListQueryDto {
|
||||
/**
|
||||
* 父目录ID,默认0(根目录)
|
||||
*/
|
||||
@ -0,0 +1,109 @@
|
||||
package org.dromara.quality.domain.vo;
|
||||
|
||||
import org.dromara.quality.domain.QltFileFolder;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 质量会议纪要视图对象 qlt_file_folder
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = QltFileFolder.class)
|
||||
public class QltFileFolderVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ExcelProperty(value = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@ExcelProperty(value = "项目id")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 名称(文件名或文件夹名)
|
||||
*/
|
||||
@ExcelProperty(value = "名称", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "文=件名或文件夹名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父级ID(0表示根目录)
|
||||
*/
|
||||
@ExcelProperty(value = "父级ID", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=表示根目录")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 类型(1-文件夹,2-文件)
|
||||
*/
|
||||
@ExcelProperty(value = "类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "1=-文件夹,2-文件")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 层级(根目录为1,子级+1)
|
||||
*/
|
||||
@ExcelProperty(value = "层级", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "根=目录为1,子级+1")
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 同层级排序号
|
||||
*/
|
||||
@ExcelProperty(value = "同层级排序号")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 层级路径(如:1,2,3 表示ID为1→2→3的层级)
|
||||
*/
|
||||
@ExcelProperty(value = "层级路径", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "如=:1,2,3,表=示ID为1→2→3的层级")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
@ExcelProperty(value = "文件id")
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
@ExcelProperty(value = "文件后缀")
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
@ExcelProperty(value = "存储路径")
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ExcelProperty(value = "")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package org.dromara.quality.domain.vo.fileFolder;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QltFileFolderTreeVO {
|
||||
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称(文件名或文件夹名)
|
||||
*/
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
* 父级ID(0表示根目录)
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 1-文件夹,2-文件
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 层级(根目录为1,子级+1)
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 同层级排序号
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* 子级
|
||||
*/
|
||||
private List<QltFileFolderTreeVO> children;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package org.dromara.quality.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.quality.domain.QltFileFolder;
|
||||
import org.dromara.quality.domain.vo.QltFileFolderVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 质量会议纪要Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
public interface QltFileFolderMapper extends BaseMapperPlus<QltFileFolder, QltFileFolderVo> {
|
||||
|
||||
|
||||
void batchUpdateChildPaths(
|
||||
@Param("oldPath") String oldPath,
|
||||
@Param("newPath") String newPath,
|
||||
@Param("levelDiff") int levelDiff,
|
||||
@Param("parentId") Long parentId);
|
||||
}
|
||||
@ -0,0 +1,115 @@
|
||||
package org.dromara.quality.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.quality.domain.dto.fileFolder.QltFileFolderCreateDTO;
|
||||
import org.dromara.quality.domain.dto.fileFolder.QltListQueryDto;
|
||||
import org.dromara.quality.domain.vo.QltFileFolderVo;
|
||||
import org.dromara.quality.domain.bo.QltFileFolderBo;
|
||||
import org.dromara.quality.domain.QltFileFolder;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 质量会议纪要Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
public interface IQltFileFolderService extends IService<QltFileFolder>{
|
||||
|
||||
/**
|
||||
* 查询质量会议纪要
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 质量会议纪要
|
||||
*/
|
||||
QltFileFolderVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询质量会议纪要列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 质量会议纪要分页列表
|
||||
*/
|
||||
TableDataInfo<QltFileFolderVo> queryPageList(QltFileFolderBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的质量会议纪要列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 质量会议纪要列表
|
||||
*/
|
||||
List<QltFileFolderVo> queryList(QltFileFolderBo bo);
|
||||
|
||||
/**
|
||||
* 新增质量会议纪要
|
||||
*
|
||||
* @param bo 质量会议纪要
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(QltFileFolderBo bo);
|
||||
|
||||
/**
|
||||
* 修改质量会议纪要
|
||||
*
|
||||
* @param bo 质量会议纪要
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(QltFileFolderBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除质量会议纪要信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
List<QltFileFolderVo> listAll(QltListQueryDto dto);
|
||||
|
||||
/**
|
||||
* 创建文件或文件夹
|
||||
*/
|
||||
QltFileFolder createFileOrFolder(QltFileFolderCreateDTO dto);
|
||||
|
||||
/**
|
||||
* 删除文件或文件夹(级联删除子项)
|
||||
*/
|
||||
boolean deleteFileOrFolder(Long id);
|
||||
|
||||
/**
|
||||
* 移动文件或文件夹到指定目录
|
||||
*/
|
||||
boolean moveFileOrFolder(Long id, Long targetParentId);
|
||||
|
||||
/**
|
||||
* 上传并解压ZIP文件
|
||||
*/
|
||||
String uploadAndUnzip(MultipartFile file, Long parentId, Long projectId) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取指定目录的树形结构(一次性加载所有层级)
|
||||
* @return 树形结构列表
|
||||
*/
|
||||
String unzip(Long id, Long parentId);
|
||||
|
||||
/**
|
||||
* 重命名文件或文件夹
|
||||
*/
|
||||
Boolean reName(Long id,String name);
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
void download(@PathVariable Long id, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@ -0,0 +1,585 @@
|
||||
package org.dromara.quality.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.oss.core.OssClient;
|
||||
import org.dromara.common.oss.factory.OssFactory;
|
||||
import org.dromara.quality.domain.dto.fileFolder.QltFileFolderCreateDTO;
|
||||
import org.dromara.quality.domain.dto.fileFolder.QltListQueryDto;
|
||||
import org.dromara.safety.domain.HseFileFolder;
|
||||
import org.dromara.safety.domain.dto.fileFolder.FileFolderCreateDTO;
|
||||
import org.dromara.safety.domain.vo.HseFileFolderVo;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.quality.domain.bo.QltFileFolderBo;
|
||||
import org.dromara.quality.domain.vo.QltFileFolderVo;
|
||||
import org.dromara.quality.domain.QltFileFolder;
|
||||
import org.dromara.quality.mapper.QltFileFolderMapper;
|
||||
import org.dromara.quality.service.IQltFileFolderService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* 质量会议纪要Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class QltFileFolderServiceImpl extends ServiceImpl<QltFileFolderMapper, QltFileFolder> implements IQltFileFolderService {
|
||||
|
||||
private final QltFileFolderMapper baseMapper;
|
||||
|
||||
private final ISysOssService ossService;
|
||||
|
||||
/**
|
||||
* 查询质量会议纪要
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 质量会议纪要
|
||||
*/
|
||||
@Override
|
||||
public QltFileFolderVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询质量会议纪要列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 质量会议纪要分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<QltFileFolderVo> queryPageList(QltFileFolderBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<QltFileFolder> lqw = buildQueryWrapper(bo);
|
||||
Page<QltFileFolderVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的质量会议纪要列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 质量会议纪要列表
|
||||
*/
|
||||
@Override
|
||||
public List<QltFileFolderVo> queryList(QltFileFolderBo bo) {
|
||||
LambdaQueryWrapper<QltFileFolder> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<QltFileFolder> buildQueryWrapper(QltFileFolderBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<QltFileFolder> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(QltFileFolder::getId);
|
||||
lqw.eq(bo.getProjectId() != null, QltFileFolder::getProjectId, bo.getProjectId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getName()), QltFileFolder::getName, bo.getName());
|
||||
lqw.eq(bo.getParentId() != null, QltFileFolder::getParentId, bo.getParentId());
|
||||
lqw.eq(bo.getType() != null, QltFileFolder::getType, bo.getType());
|
||||
lqw.eq(bo.getLevel() != null, QltFileFolder::getLevel, bo.getLevel());
|
||||
lqw.eq(bo.getSort() != null, QltFileFolder::getSort, bo.getSort());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPath()), QltFileFolder::getPath, bo.getPath());
|
||||
lqw.eq(bo.getFileId() != null, QltFileFolder::getFileId, bo.getFileId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), QltFileFolder::getFileSuffix, bo.getFileSuffix());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFilePath()), QltFileFolder::getFilePath, bo.getFilePath());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增质量会议纪要
|
||||
*
|
||||
* @param bo 质量会议纪要
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(QltFileFolderBo bo) {
|
||||
QltFileFolder add = MapstructUtils.convert(bo, QltFileFolder.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改质量会议纪要
|
||||
*
|
||||
* @param bo 质量会议纪要
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(QltFileFolderBo bo) {
|
||||
QltFileFolder update = MapstructUtils.convert(bo, QltFileFolder.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(QltFileFolder entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除质量会议纪要信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QltFileFolderVo> listAll(QltListQueryDto dto) {
|
||||
|
||||
LambdaQueryWrapper<QltFileFolder> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(QltFileFolder::getId);
|
||||
lqw.orderByAsc(QltFileFolder::getSort);
|
||||
|
||||
lqw.eq(QltFileFolder::getProjectId, dto.getProjectId());
|
||||
lqw.eq(QltFileFolder::getParentId, dto.getParentId());
|
||||
lqw.eq(dto.getType() != null, QltFileFolder::getType, dto.getType());
|
||||
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QltFileFolder createFileOrFolder(QltFileFolderCreateDTO dto) {
|
||||
// 1. 验证父目录是否存在
|
||||
if (dto.getParentId() != 0) {
|
||||
QltFileFolder parent = getById(dto.getParentId());
|
||||
if (parent == null || parent.getType() != 1) { // 父级必须是文件夹
|
||||
throw new ServiceException("父目录不存在或不是文件夹");
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 构建新文件/文件夹对象
|
||||
QltFileFolder entity = new QltFileFolder();
|
||||
entity.setProjectId(dto.getProjectId());
|
||||
entity.setName(dto.getName());
|
||||
entity.setParentId(dto.getParentId());
|
||||
entity.setType(dto.getType());
|
||||
entity.setSort(dto.getSort() != null ? dto.getSort() : 0);
|
||||
entity.setRemark(dto.getRemark());
|
||||
entity.setFileId(dto.getFileId());
|
||||
|
||||
|
||||
// 3. 设置层级和路径
|
||||
if (dto.getParentId() == 0) { // 根目录
|
||||
entity.setLevel(1);
|
||||
entity.setPath("," + entity.getId() + ","); // ID会在插入后自动生成,这里先占位
|
||||
} else { // 子目录/文件
|
||||
QltFileFolder parent = getById(dto.getParentId());
|
||||
entity.setLevel(parent.getLevel() + 1);
|
||||
entity.setPath(parent.getPath() + entity.getId() + ","); // ID会在插入后更新
|
||||
}
|
||||
|
||||
// 4. 处理文件特有属性
|
||||
if (dto.getType() == 2) { // 如果是文件
|
||||
entity.setFileSuffix(dto.getFileSuffix());
|
||||
entity.setFilePath(dto.getFilePath());
|
||||
}
|
||||
|
||||
// 5. 保存并更新路径(因为ID是自增的,需要先保存再更新路径)
|
||||
save(entity);
|
||||
|
||||
// 6. 修正路径中的ID
|
||||
if (dto.getParentId() == 0) {
|
||||
entity.setPath("," + entity.getId() + ",");
|
||||
} else {
|
||||
QltFileFolder parent = getById(dto.getParentId());
|
||||
entity.setPath(parent.getPath() + entity.getId() + ",");
|
||||
}
|
||||
updateById(entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteFileOrFolder(Long id) {
|
||||
QltFileFolder entity = getById(id);
|
||||
if (entity == null) {
|
||||
throw new ServiceException("文件/文件夹不存在");
|
||||
}
|
||||
|
||||
// 1. 删除自身及所有子项(通过path匹配)
|
||||
LambdaQueryWrapper<QltFileFolder> queryWrapper = Wrappers.<QltFileFolder>lambdaQuery()
|
||||
.like(QltFileFolder::getPath, "," + id + ",");
|
||||
|
||||
return remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean moveFileOrFolder(Long id, Long targetParentId) {
|
||||
// 1. 验证源文件和目标目录是否存在
|
||||
QltFileFolder source = getById(id);
|
||||
if (source == null) {
|
||||
throw new ServiceException("源文件/文件夹不存在");
|
||||
}
|
||||
|
||||
QltFileFolder targetParent = getById(targetParentId);
|
||||
if (targetParent == null || targetParent.getType() != 1) {
|
||||
throw new ServiceException("目标目录不存在或不是文件夹");
|
||||
}
|
||||
|
||||
// 2. 防止循环移动(不能移动到自身或子目录下)
|
||||
if (targetParent.getPath().contains(source.getPath())) {
|
||||
throw new ServiceException("不能将文件夹移动到其子目录下");
|
||||
}
|
||||
|
||||
// 3. 获取原路径和新路径的前缀
|
||||
String oldPath = source.getPath();
|
||||
String oldParentPath = source.getParentId() == 0 ? ",0," : getById(source.getParentId()).getPath();
|
||||
String newParentPath = targetParent.getPath();
|
||||
int oldLevel = source.getLevel();
|
||||
|
||||
// 4. 计算新路径和新层级
|
||||
String newPath = newParentPath + id + ",";
|
||||
int newLevel = targetParent.getLevel() + 1;
|
||||
|
||||
// 5. 更新自身信息
|
||||
source.setParentId(targetParentId);
|
||||
source.setLevel(newLevel);
|
||||
source.setPath(newPath);
|
||||
updateById(source);
|
||||
|
||||
// 6. 更新所有子项的路径和层级
|
||||
if (source.getType() == 1) { // 如果是文件夹,需要更新其子项
|
||||
// 计算路径替换的前后缀
|
||||
String pathReplaceFrom = oldPath;
|
||||
String pathReplaceTo = newPath;
|
||||
int levelDiff = newLevel - oldLevel; // 层级变化量
|
||||
|
||||
// 批量更新子项
|
||||
baseMapper.batchUpdateChildPaths(pathReplaceFrom, pathReplaceTo, levelDiff, id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public String uploadAndUnzip(MultipartFile file, Long parentId, Long projectId) throws Exception {
|
||||
// 1. 参数验证
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new ServiceException("上传文件不能为空");
|
||||
}
|
||||
|
||||
// 2. 验证文件类型是否为ZIP
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
if (originalFilename == null || !originalFilename.toLowerCase().endsWith(".zip")) {
|
||||
throw new ServiceException("只支持上传ZIP格式的文件");
|
||||
}
|
||||
|
||||
// 3. 验证父目录是否存在且为文件夹
|
||||
QltFileFolder parentFolder = null;
|
||||
if (parentId != null && parentId != 0) {
|
||||
parentFolder = getById(parentId);
|
||||
if (parentFolder == null || parentFolder.getType() != 1) {
|
||||
throw new ServiceException("指定的父目录不存在或不是文件夹");
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 创建临时文件用于解压
|
||||
File tempZipFile = File.createTempFile("upload_", ".zip");
|
||||
try {
|
||||
// 5. 保存上传的文件到临时位置
|
||||
file.transferTo(tempZipFile);
|
||||
|
||||
// 6. 解压ZIP文件
|
||||
String unzipResult = doUnzipFile(tempZipFile, parentId, projectId, parentFolder);
|
||||
|
||||
return unzipResult;
|
||||
} finally {
|
||||
// 7. 清理临时文件
|
||||
if (tempZipFile.exists()) {
|
||||
tempZipFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 实际执行解压操作的方法
|
||||
*
|
||||
* @param zipFile ZIP文件
|
||||
* @param parentId 父目录ID
|
||||
* @param projectId 项目ID
|
||||
* @param parentFolder 父目录对象
|
||||
* @return 解压结果信息
|
||||
* @throws Exception 解压过程中可能出现的异常
|
||||
*/
|
||||
private String doUnzipFile(File zipFile, Long parentId, Long projectId, QltFileFolder parentFolder) throws Exception {
|
||||
// 用于记录解压的文件数量
|
||||
int fileCount = 0;
|
||||
int folderCount = 0;
|
||||
|
||||
// 获取父级路径信息
|
||||
String parentPath = parentId == null || parentId == 0 ? "," : parentFolder.getPath();
|
||||
int parentLevel = parentId == null || parentId == 0 ? 0 : parentFolder.getLevel();
|
||||
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile), Charset.forName("GBK"))) {
|
||||
ZipEntry entry;
|
||||
while ((entry = zis.getNextEntry()) != null) {
|
||||
// 跳过目录项(目录会根据文件路径自动创建)
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = entry.getName();
|
||||
// 处理中文文件名乱码问题
|
||||
if (!Charset.forName("GBK").newEncoder().canEncode(entryName)) {
|
||||
// 尝试用UTF-8编码解析
|
||||
entryName = new String(entryName.getBytes("ISO-8859-1"), "UTF-8");
|
||||
}
|
||||
|
||||
// 分离路径和文件名
|
||||
String[] pathParts = entryName.split("/");
|
||||
String fileName = pathParts[pathParts.length - 1];
|
||||
|
||||
// 构造文件在系统中的虚拟路径
|
||||
Long currentParentId = parentId == null ? 0L : parentId;
|
||||
String currentPath = parentPath;
|
||||
|
||||
// 如果ZIP中有目录结构,则需要逐级创建文件夹
|
||||
for (int i = 0; i < pathParts.length - 1; i++) {
|
||||
String folderName = pathParts[i];
|
||||
if (folderName.isEmpty()) continue;
|
||||
|
||||
// 查找是否已存在同名文件夹
|
||||
LambdaQueryWrapper<QltFileFolder> folderQuery = Wrappers.lambdaQuery();
|
||||
folderQuery.eq(QltFileFolder::getProjectId, projectId)
|
||||
.eq(QltFileFolder::getParentId, currentParentId)
|
||||
.eq(QltFileFolder::getName, folderName)
|
||||
.eq(QltFileFolder::getType, 1); // 文件夹类型
|
||||
|
||||
QltFileFolder existingFolder = getOne(folderQuery);
|
||||
|
||||
if (existingFolder == null) {
|
||||
// 创建新的文件夹
|
||||
QltFileFolder newFolder = new QltFileFolder();
|
||||
newFolder.setProjectId(projectId);
|
||||
newFolder.setName(folderName);
|
||||
newFolder.setParentId(currentParentId);
|
||||
newFolder.setType(1); // 文件夹
|
||||
newFolder.setLevel(parentLevel + i + 1);
|
||||
newFolder.setSort(0);
|
||||
newFolder.setPath(currentPath);
|
||||
|
||||
// 先保存获取ID
|
||||
save(newFolder);
|
||||
|
||||
// 更新路径,格式为 ,parentId,childId,
|
||||
newFolder.setPath(currentPath + newFolder.getId() + ",");
|
||||
updateById(newFolder);
|
||||
|
||||
currentParentId = newFolder.getId();
|
||||
currentPath = newFolder.getPath();
|
||||
folderCount++;
|
||||
} else {
|
||||
currentParentId = existingFolder.getId();
|
||||
currentPath = existingFolder.getPath();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建文件记录
|
||||
QltFileFolder fileRecord = new QltFileFolder();
|
||||
fileRecord.setProjectId(projectId);
|
||||
fileRecord.setName(fileName);
|
||||
fileRecord.setParentId(currentParentId);
|
||||
fileRecord.setType(2); // 文件类型
|
||||
fileRecord.setLevel(parentLevel + pathParts.length);
|
||||
// 文件路径格式为 ,parentId,fileId,
|
||||
fileRecord.setPath(currentPath + fileRecord.getId() + ",");
|
||||
|
||||
// 设置文件扩展名
|
||||
int dotIndex = fileName.lastIndexOf(".");
|
||||
if (dotIndex > 0 && dotIndex < fileName.length() - 1) {
|
||||
fileRecord.setFileSuffix(fileName.substring(dotIndex + 1));
|
||||
}
|
||||
// 上传文件内容到OSS并设置文件路径
|
||||
// 上传文件内容到OSS并设置文件路径
|
||||
try {
|
||||
// 从ZIP流中读取文件内容
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[32768];
|
||||
int bytesRead;
|
||||
while ((bytesRead = zis.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
byte[] fileContent = baos.toByteArray();
|
||||
|
||||
// 检查文件长度,如果为0则跳过保存
|
||||
if (fileContent.length > 0) {
|
||||
// 直接使用字节流上传到OSS,避免创建临时文件
|
||||
try (ByteArrayInputStream bais = new ByteArrayInputStream(fileContent)) {
|
||||
String contentType = FileUtils.getMimeType(fileName);
|
||||
SysOssVo ossVo = ossService.upload(bais, fileName, contentType, (long) fileContent.length);
|
||||
|
||||
// 设置真实的文件路径
|
||||
fileRecord.setFilePath(ossVo.getUrl());
|
||||
fileRecord.setFileId(ossVo.getOssId());
|
||||
}
|
||||
|
||||
save(fileRecord);
|
||||
|
||||
// 更新文件的路径(因为ID是自增的,需要先保存再更新路径)
|
||||
fileRecord.setPath(currentPath + fileRecord.getId() + ",");
|
||||
updateById(fileRecord);
|
||||
|
||||
fileCount++;
|
||||
}
|
||||
// 如果文件长度为0,则跳过保存操作
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("文件上传失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
zis.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
return String.format("解压完成,共创建 %d 个文件夹,%d 个文件", folderCount, fileCount);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public String unzip(Long id, Long parentId) {
|
||||
// 1. 参数验证
|
||||
if (id == null) {
|
||||
throw new ServiceException("文件ID不能为空");
|
||||
}
|
||||
|
||||
// 2. 获取要解压的ZIP文件
|
||||
QltFileFolder zipFile = getById(id);
|
||||
if (zipFile == null) {
|
||||
throw new ServiceException("指定的文件不存在");
|
||||
}
|
||||
|
||||
// 3. 验证是否为ZIP文件
|
||||
if (!"zip".equalsIgnoreCase(zipFile.getFileSuffix())) {
|
||||
throw new ServiceException("只能解压ZIP格式的文件");
|
||||
}
|
||||
|
||||
// 4. 验证文件路径是否存在
|
||||
if (StringUtils.isBlank(zipFile.getFilePath())) {
|
||||
throw new ServiceException("文件存储路径不存在");
|
||||
}
|
||||
|
||||
// 5. 验证目标目录是否存在且为文件夹
|
||||
QltFileFolder parentFolder = null;
|
||||
if (parentId != null && parentId != 0) {
|
||||
parentFolder = getById(parentId);
|
||||
if (parentFolder == null || parentFolder.getType() != 1) {
|
||||
throw new ServiceException("指定的目标目录不存在或不是文件夹");
|
||||
}
|
||||
}
|
||||
|
||||
// 6. 下载ZIP文件到临时位置
|
||||
try {
|
||||
// 从URL下载文件
|
||||
Long fileId = zipFile.getFileId();
|
||||
File tempZipFile = downloadFileToTemp(fileId);
|
||||
|
||||
if (tempZipFile == null || !tempZipFile.exists()) {
|
||||
throw new ServiceException("下载文件失败");
|
||||
}
|
||||
|
||||
try {
|
||||
// 7. 解压ZIP文件
|
||||
String unzipResult = doUnzipFile(tempZipFile, parentId, zipFile.getProjectId(), parentFolder);
|
||||
return unzipResult;
|
||||
} finally {
|
||||
// 8. 清理临时文件
|
||||
if (tempZipFile.exists()) {
|
||||
tempZipFile.delete();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("解压文件失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从URL下载文件到临时位置
|
||||
*
|
||||
* @param fileId 文件id
|
||||
* @return 临时文件
|
||||
* @throws Exception 下载过程中的异常
|
||||
*/
|
||||
private File downloadFileToTemp(Long fileId) throws Exception {
|
||||
SysOssVo sysOss = ossService.getById(fileId);
|
||||
if (ObjectUtil.isNull(sysOss)) {
|
||||
throw new ServiceException("文件数据不存在!");
|
||||
}
|
||||
|
||||
OssClient storage = OssFactory.instance(sysOss.getService());
|
||||
// 直接使用OssClient返回的临时文件路径
|
||||
Path tempPath = storage.fileDownload(sysOss.getUrl());
|
||||
|
||||
return tempPath.toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean reName(Long id, String name) {
|
||||
QltFileFolder fileFolder = getById(id);
|
||||
if (fileFolder != null) {
|
||||
fileFolder.setName(name);
|
||||
return updateById(fileFolder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(Long id, HttpServletResponse response) throws IOException {
|
||||
|
||||
QltFileFolder fileFolder = getById(id);
|
||||
|
||||
if(fileFolder == null){
|
||||
throw new ServiceException("文件数据不存在!");
|
||||
}
|
||||
Long ossId = fileFolder.getFileId();
|
||||
SysOssVo sysOss = ossService.getById(ossId);
|
||||
if (ObjectUtil.isNull(sysOss)) {
|
||||
throw new ServiceException("文件数据不存在!");
|
||||
}
|
||||
FileUtils.setAttachmentResponseHeader(response, fileFolder.getName()+"."+fileFolder.getFileSuffix());
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
|
||||
OssClient storage = OssFactory.instance(sysOss.getService());
|
||||
storage.download(sysOss.getFileName(), response.getOutputStream(), response::setContentLengthLong);
|
||||
}
|
||||
}
|
||||
@ -1,35 +1,25 @@
|
||||
package org.dromara.safety.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.quality.domain.dto.fileFolder.SafeListQueryDto;
|
||||
import org.dromara.safety.domain.HseFileFolder;
|
||||
import org.dromara.safety.domain.dto.fileFolder.FileFolderCreateDTO;
|
||||
import org.dromara.safety.domain.dto.fileFolder.FileFolderMoveDTO;
|
||||
import org.dromara.safety.domain.dto.fileFolder.ListQueryDto;
|
||||
import org.dromara.safety.domain.vo.fileFolder.FileFolderTreeVO;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
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.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.safety.domain.vo.HseFileFolderVo;
|
||||
import org.dromara.safety.domain.bo.HseFileFolderBo;
|
||||
import org.dromara.safety.service.IHseFileFolderService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
@ -49,8 +39,9 @@ public class HseFileFolderController extends BaseController {
|
||||
/**
|
||||
* 查询会议纪要列表
|
||||
*/
|
||||
@SaCheckPermission("safety:fileFolder:listAll")
|
||||
@GetMapping("/list-all")
|
||||
public R<List<HseFileFolderVo>> listAll(ListQueryDto dto) {
|
||||
public R<List<HseFileFolderVo>> listAll(SafeListQueryDto dto) {
|
||||
return R.ok(hseFileFolderService.listAll(dto));
|
||||
}
|
||||
|
||||
@ -59,7 +50,7 @@ public class HseFileFolderController extends BaseController {
|
||||
* @return 树形结构列表
|
||||
*/
|
||||
@GetMapping("/tree-all")
|
||||
public R<List<FileFolderTreeVO>> treeAll(ListQueryDto dto) {
|
||||
public R<List<FileFolderTreeVO>> treeAll(SafeListQueryDto dto) {
|
||||
|
||||
// 1. 查询所有子项(利用path前缀匹配,一次性加载所有层级)
|
||||
List<HseFileFolder> allItems = hseFileFolderService.list(new LambdaQueryWrapper<HseFileFolder>()
|
||||
@ -102,6 +93,7 @@ public class HseFileFolderController extends BaseController {
|
||||
/**
|
||||
* 创建文件或文件夹
|
||||
*/
|
||||
@SaCheckPermission("safety:fileFolder:create")
|
||||
@PostMapping("/create")
|
||||
public R<HseFileFolder> create(@RequestBody FileFolderCreateDTO dto) {
|
||||
return R.ok(hseFileFolderService.createFileOrFolder(dto));
|
||||
@ -110,15 +102,21 @@ public class HseFileFolderController extends BaseController {
|
||||
/**
|
||||
* 删除文件或文件夹(级联删除子项)
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
|
||||
@SaCheckPermission("safety:fileFolder:delete")
|
||||
@DeleteMapping("/{ids}")
|
||||
@Transactional
|
||||
public R<Boolean> delete(@PathVariable Long id) {
|
||||
return R.ok(hseFileFolderService.deleteFileOrFolder(id));
|
||||
public R<Boolean> delete(@PathVariable List<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
hseFileFolderService.deleteFileOrFolder(id);
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动文件或文件夹到指定目录
|
||||
*/
|
||||
@SaCheckPermission("safety:fileFolder:move")
|
||||
@PostMapping("/move")
|
||||
@Transactional
|
||||
public R<Boolean> move(@RequestBody FileFolderMoveDTO dto) {
|
||||
@ -128,6 +126,7 @@ public class HseFileFolderController extends BaseController {
|
||||
/**
|
||||
* 上传ZIP文件并自动解压到指定目录(支持多层级)
|
||||
*/
|
||||
@SaCheckPermission("safety:fileFolder:create")
|
||||
@PostMapping("/uploadAndUnzip")
|
||||
public R<String> uploadAndUnzip(
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@ -145,14 +144,25 @@ public class HseFileFolderController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/unzip")
|
||||
public R<String> unzip(@RequestParam("id") Long id,
|
||||
@RequestParam("parentId") Long parentId) {
|
||||
return R.ok(hseFileFolderService.unzip(id, parentId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("safety:fileFolder:reName")
|
||||
@PutMapping("/reName")
|
||||
public R<Boolean> reName(@RequestParam("id") Long id,
|
||||
@RequestParam("name") String name) {
|
||||
return R.ok(hseFileFolderService.reName(id,name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@SaCheckPermission("safety:fileFolder:download")
|
||||
@GetMapping("/download/{id}")
|
||||
public void download(@PathVariable Long id, HttpServletResponse response) throws IOException {
|
||||
hseFileFolderService.download(id, response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package org.dromara.quality.domain.dto.fileFolder;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SafeListQueryDto {
|
||||
/**
|
||||
* 父目录ID,默认0(根目录)
|
||||
*/
|
||||
@NotNull(message = "父目录ID不能为空")
|
||||
private Long parentId;
|
||||
|
||||
|
||||
/**
|
||||
* 类型:1-文件夹,2-文件,null-全部
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
|
||||
@NotNull(message = "项目不能为空")
|
||||
private Long projectId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
package org.dromara.safety.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.quality.domain.dto.fileFolder.SafeListQueryDto;
|
||||
import org.dromara.safety.domain.dto.fileFolder.FileFolderCreateDTO;
|
||||
import org.dromara.safety.domain.dto.fileFolder.ListQueryDto;
|
||||
import org.dromara.safety.domain.vo.HseFileFolderVo;
|
||||
import org.dromara.safety.domain.bo.HseFileFolderBo;
|
||||
import org.dromara.safety.domain.HseFileFolder;
|
||||
@ -9,8 +10,10 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -73,7 +76,7 @@ public interface IHseFileFolderService extends IService<HseFileFolder>{
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
|
||||
List<HseFileFolderVo> listAll(ListQueryDto dto);
|
||||
List<HseFileFolderVo> listAll(SafeListQueryDto dto);
|
||||
|
||||
/**
|
||||
* 创建文件或文件夹
|
||||
@ -100,4 +103,14 @@ public interface IHseFileFolderService extends IService<HseFileFolder>{
|
||||
* @return 树形结构列表
|
||||
*/
|
||||
String unzip(Long id, Long parentId);
|
||||
|
||||
/**
|
||||
* 重命名文件或文件夹
|
||||
*/
|
||||
Boolean reName(Long id,String name);
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
void download(@PathVariable Long id, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
||||
@ -1,17 +1,25 @@
|
||||
package org.dromara.safety.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.oss.core.OssClient;
|
||||
import org.dromara.common.oss.factory.OssFactory;
|
||||
import org.dromara.quality.domain.dto.fileFolder.SafeListQueryDto;
|
||||
import org.dromara.safety.domain.dto.fileFolder.FileFolderCreateDTO;
|
||||
import org.dromara.safety.domain.dto.fileFolder.ListQueryDto;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.safety.domain.bo.HseFileFolderBo;
|
||||
import org.dromara.safety.domain.vo.HseFileFolderVo;
|
||||
@ -21,9 +29,9 @@ import org.dromara.safety.service.IHseFileFolderService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
@ -39,6 +47,7 @@ import java.util.zip.ZipInputStream;
|
||||
public class HseFileFolderServiceImpl extends ServiceImpl<HseFileFolderMapper, HseFileFolder> implements IHseFileFolderService {
|
||||
|
||||
private final HseFileFolderMapper baseMapper;
|
||||
private final ISysOssService ossService;
|
||||
|
||||
/**
|
||||
* 查询会议纪要
|
||||
@ -148,7 +157,7 @@ public class HseFileFolderServiceImpl extends ServiceImpl<HseFileFolderMapper, H
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HseFileFolderVo> listAll(ListQueryDto dto) {
|
||||
public List<HseFileFolderVo> listAll(SafeListQueryDto dto) {
|
||||
|
||||
LambdaQueryWrapper<HseFileFolder> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(HseFileFolder::getId);
|
||||
@ -404,29 +413,60 @@ public class HseFileFolderServiceImpl extends ServiceImpl<HseFileFolderMapper, H
|
||||
// 创建文件记录
|
||||
HseFileFolder fileRecord = new HseFileFolder();
|
||||
fileRecord.setProjectId(projectId);
|
||||
fileRecord.setName(fileName);
|
||||
fileRecord.setParentId(currentParentId);
|
||||
fileRecord.setType(2); // 文件类型
|
||||
fileRecord.setLevel(parentLevel + pathParts.length);
|
||||
// 文件路径格式为 ,parentId,fileId,
|
||||
fileRecord.setPath(currentPath + fileRecord.getId() + ",");
|
||||
|
||||
// 设置文件扩展名
|
||||
// 设置文件名(不包含扩展名)和文件扩展名
|
||||
int dotIndex = fileName.lastIndexOf(".");
|
||||
if (dotIndex > 0 && dotIndex < fileName.length() - 1) {
|
||||
fileRecord.setFileSuffix(fileName.substring(dotIndex + 1));
|
||||
if (dotIndex > 0) {
|
||||
// 设置文件名(不包含扩展名)
|
||||
fileRecord.setName(fileName.substring(0, dotIndex));
|
||||
// 设置文件扩展名
|
||||
if (dotIndex < fileName.length() - 1) {
|
||||
fileRecord.setFileSuffix(fileName.substring(dotIndex + 1));
|
||||
}
|
||||
} else {
|
||||
// 没有扩展名的情况
|
||||
fileRecord.setName(fileName);
|
||||
}
|
||||
// 上传文件内容到OSS并设置文件路径
|
||||
try {
|
||||
// 从ZIP流中读取文件内容
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[32768];
|
||||
int bytesRead;
|
||||
while ((bytesRead = zis.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
byte[] fileContent = baos.toByteArray();
|
||||
|
||||
// TODO: 这里应该与实际文件存储服务集成,设置真实的文件路径
|
||||
fileRecord.setFilePath(""); // 实际应用中应设置真实文件存储路径
|
||||
// 检查文件长度,如果为0则跳过保存
|
||||
if (fileContent.length > 0) {
|
||||
// 直接使用字节流上传到OSS,避免创建临时文件
|
||||
try (ByteArrayInputStream bais = new ByteArrayInputStream(fileContent)) {
|
||||
String contentType = FileUtils.getMimeType(fileName);
|
||||
SysOssVo ossVo = ossService.upload(bais, fileName, contentType, (long) fileContent.length);
|
||||
|
||||
save(fileRecord);
|
||||
// 设置真实的文件路径
|
||||
fileRecord.setFilePath(ossVo.getUrl());
|
||||
fileRecord.setFileId(ossVo.getOssId());
|
||||
}
|
||||
|
||||
// 更新文件的路径(因为ID是自增的,需要先保存再更新路径)
|
||||
fileRecord.setPath(currentPath + fileRecord.getId() + ",");
|
||||
updateById(fileRecord);
|
||||
save(fileRecord);
|
||||
|
||||
fileCount++;
|
||||
// 更新文件的路径(因为ID是自增的,需要先保存再更新路径)
|
||||
fileRecord.setPath(currentPath + fileRecord.getId() + ",");
|
||||
updateById(fileRecord);
|
||||
|
||||
fileCount++;
|
||||
}
|
||||
// 如果文件长度为0,则跳过保存操作
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("文件上传失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
zis.closeEntry();
|
||||
}
|
||||
@ -472,8 +512,8 @@ public class HseFileFolderServiceImpl extends ServiceImpl<HseFileFolderMapper, H
|
||||
// 6. 下载ZIP文件到临时位置
|
||||
try {
|
||||
// 从URL下载文件
|
||||
String fileUrl = zipFile.getFilePath();
|
||||
File tempZipFile = downloadFileToTemp(fileUrl);
|
||||
Long fileId = zipFile.getFileId();
|
||||
File tempZipFile = downloadFileToTemp(fileId);
|
||||
|
||||
if (tempZipFile == null || !tempZipFile.exists()) {
|
||||
throw new ServiceException("下载文件失败");
|
||||
@ -497,40 +537,49 @@ public class HseFileFolderServiceImpl extends ServiceImpl<HseFileFolderMapper, H
|
||||
/**
|
||||
* 从URL下载文件到临时位置
|
||||
*
|
||||
* @param fileUrl 文件URL
|
||||
* @param fileId 文件id
|
||||
* @return 临时文件
|
||||
* @throws Exception 下载过程中的异常
|
||||
*/
|
||||
private File downloadFileToTemp(String fileUrl) throws Exception {
|
||||
// 创建临时文件
|
||||
File tempFile = File.createTempFile("download_", ".zip");
|
||||
|
||||
// 使用Apache HttpClient或其他HTTP客户端下载文件
|
||||
// 这里简化处理,实际项目中应根据具体文件存储服务实现
|
||||
|
||||
// 示例实现(需要根据实际文件存储服务调整):
|
||||
/*
|
||||
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||
HttpGet httpGet = new HttpGet(fileUrl);
|
||||
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null) {
|
||||
try (InputStream inputStream = entity.getContent();
|
||||
FileOutputStream outputStream = new FileOutputStream(tempFile)) {
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
private File downloadFileToTemp(Long fileId) throws Exception {
|
||||
SysOssVo sysOss = ossService.getById(fileId);
|
||||
if (ObjectUtil.isNull(sysOss)) {
|
||||
throw new ServiceException("文件数据不存在!");
|
||||
}
|
||||
|
||||
OssClient storage = OssFactory.instance(sysOss.getService());
|
||||
// 直接使用OssClient返回的临时文件路径
|
||||
Path tempPath = storage.fileDownload(sysOss.getUrl());
|
||||
|
||||
return tempPath.toFile();
|
||||
}
|
||||
*/
|
||||
|
||||
// 如果使用MinIO或其他存储服务,需要相应调整实现
|
||||
@Override
|
||||
public Boolean reName(Long id, String name) {
|
||||
HseFileFolder fileFolder = getById(id);
|
||||
if (fileFolder != null) {
|
||||
fileFolder.setName(name);
|
||||
return updateById(fileFolder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 占位实现,实际需要根据文件存储服务来实现
|
||||
throw new ServiceException("未实现文件下载功能,请根据实际文件存储服务完善此方法");
|
||||
@Override
|
||||
public void download(Long id, HttpServletResponse response) throws IOException {
|
||||
|
||||
HseFileFolder fileFolder = getById(id);
|
||||
|
||||
if(fileFolder == null){
|
||||
throw new ServiceException("文件数据不存在!");
|
||||
}
|
||||
Long ossId = fileFolder.getFileId();
|
||||
SysOssVo sysOss = ossService.getById(ossId);
|
||||
if (ObjectUtil.isNull(sysOss)) {
|
||||
throw new ServiceException("文件数据不存在!");
|
||||
}
|
||||
FileUtils.setAttachmentResponseHeader(response, fileFolder.getName()+"."+fileFolder.getFileSuffix());
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
|
||||
OssClient storage = OssFactory.instance(sysOss.getService());
|
||||
storage.download(sysOss.getFileName(), response.getOutputStream(), response::setContentLengthLong);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,6 +116,9 @@ public class SysUserBo extends BaseEntity {
|
||||
|
||||
private Long contractorId;
|
||||
|
||||
|
||||
private Long neUserId;
|
||||
|
||||
/**
|
||||
* 排除不查询的用户(工作流用)
|
||||
*/
|
||||
|
||||
@ -58,6 +58,7 @@ public class ChatFriendshipServiceImpl extends ServiceImpl<ChatFriendshipMapper,
|
||||
// if (one == null || one.isEmpty()){
|
||||
// return R.fail("该账号暂无项目组,请尽快联系管理员进行分配");
|
||||
// }
|
||||
user.setNeUserId(LoginHelper.getUserId());
|
||||
Page<SysUserVo> page = sysUserMapper.selectPageUserList(pageQuery.build(), this.buildQueryWrapper(user));
|
||||
List<SysUserVo> userVoList = page.getRecords();
|
||||
List<SysUserVo> temps = new ArrayList<>();
|
||||
@ -96,6 +97,7 @@ public class ChatFriendshipServiceImpl extends ServiceImpl<ChatFriendshipMapper,
|
||||
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
||||
wrapper.eq("u.del_flag", SystemConstants.NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(user.getUserId()), "u.user_id", user.getUserId())
|
||||
.ne(ObjectUtil.isNotNull(user.getNeUserId()), "u.user_id", user.getNeUserId())
|
||||
.like(StringUtils.isNotBlank(user.getNickName()), "u.nick_name", user.getNickName())
|
||||
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
||||
.eq(StringUtils.isNotBlank(user.getStatus()), "u.status", user.getStatus())
|
||||
@ -107,6 +109,7 @@ public class ChatFriendshipServiceImpl extends ServiceImpl<ChatFriendshipMapper,
|
||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||
wrapper.notIn("u.user_id", StringUtils.splitTo(user.getExcludeUserIds(), Convert::toLong));
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
@ -67,4 +67,6 @@ public interface IXzdCsContractInformationService extends IService<XzdCsContract
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
String queryCodeById(Long contractCode);
|
||||
}
|
||||
|
||||
@ -167,7 +167,6 @@ public class XzdCsContractChangeServiceImpl extends ServiceImpl<XzdCsContractCha
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
addzixiang(bo,add);
|
||||
String tableName = XzdClassEnum.CS_CONTRACT_CHANGE.getClassName();
|
||||
if (bo.getKkyjlx() == null || bo.getKkyjlx().isEmpty()) {
|
||||
throw new ServiceException("扣款与奖励项不能为空");
|
||||
@ -232,11 +231,6 @@ public class XzdCsContractChangeServiceImpl extends ServiceImpl<XzdCsContractCha
|
||||
lambdaQueryWrapper4.eq(XzdDeductionItems::getContractDetailsId, old.getId());
|
||||
xzdDeductionItemsService.remove(lambdaQueryWrapper4);
|
||||
|
||||
addzixiang(bo, update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
private void addzixiang(XzdCsContractChangeBo bo, XzdCsContractChange update) {
|
||||
String tableName = XzdClassEnum.CS_CONTRACT_CHANGE.getClassName();
|
||||
if (bo.getKkyjlx() == null || bo.getKkyjlx().isEmpty()) {
|
||||
throw new ServiceException("扣款与奖励项不能为空");
|
||||
@ -264,8 +258,10 @@ public class XzdCsContractChangeServiceImpl extends ServiceImpl<XzdCsContractCha
|
||||
clause.setContractDetailsId(update.getId());
|
||||
}
|
||||
xzdSettlementRulesService.saveBatch(bo.getZftk());
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
|
||||
@ -405,4 +405,9 @@ public class XzdCsContractInformationServiceImpl extends ServiceImpl<XzdCsContra
|
||||
xzdSettlementRulesService.remove(lambdaQueryWrapper3);
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryCodeById(Long contractCode) {
|
||||
return baseMapper.selectVoById(contractCode).getContractCode();
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import org.dromara.xzd.comprehensive.domain.vo.XzdCsContractSuspendVo;
|
||||
import org.dromara.xzd.comprehensive.domain.XzdCsContractSuspend;
|
||||
import org.dromara.xzd.comprehensive.mapper.XzdCsContractSuspendMapper;
|
||||
import org.dromara.xzd.comprehensive.service.IXzdCsContractSuspendService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -163,6 +164,7 @@ public class XzdCsContractSuspendServiceImpl extends ServiceImpl<XzdCsContractSu
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
|
||||
@ -100,9 +100,9 @@ public class XzdSfkCaigouFk extends BaseEntity {
|
||||
private String statCycle;
|
||||
|
||||
/**
|
||||
* 是否是研发类
|
||||
* 项目类型
|
||||
*/
|
||||
private Long isYanfa;
|
||||
private String projectType;
|
||||
|
||||
/**
|
||||
* 税率(带*,必填)
|
||||
|
||||
@ -72,7 +72,7 @@ public class XzdSfkZonhefuwuFk extends BaseEntity {
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
private Long projectId;
|
||||
private Long project;
|
||||
|
||||
/**
|
||||
* 付款单位
|
||||
@ -164,6 +164,11 @@ public class XzdSfkZonhefuwuFk extends BaseEntity {
|
||||
*/
|
||||
private BigDecimal currentPaymentRatio;
|
||||
|
||||
/**
|
||||
* 累计进度支付占累计进度应付(%)
|
||||
*/
|
||||
private BigDecimal totalPaymentRatio;
|
||||
|
||||
/**
|
||||
* 累计支付占合同比例(%)
|
||||
*/
|
||||
|
||||
@ -8,8 +8,12 @@ import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFapiao;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFukuan;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 采购合同付款业务对象 xzd_sfk_caigou_fk
|
||||
@ -31,7 +35,7 @@ public class XzdSfkCaigouFkBo extends BaseEntity {
|
||||
/**
|
||||
* 单据编码(带*,必填)
|
||||
*/
|
||||
@NotBlank(message = "单据编码(带*,必填)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "单据编码(带*,必填)不能为空", groups = { EditGroup.class })
|
||||
private String docCode;
|
||||
|
||||
/**
|
||||
@ -106,9 +110,9 @@ public class XzdSfkCaigouFkBo extends BaseEntity {
|
||||
private String statCycle;
|
||||
|
||||
/**
|
||||
* 是否是研发类
|
||||
* 项目类型
|
||||
*/
|
||||
private Long isYanfa;
|
||||
private String projectType;
|
||||
|
||||
/**
|
||||
* 税率(带*,必填)
|
||||
@ -227,5 +231,8 @@ public class XzdSfkCaigouFkBo extends BaseEntity {
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
List<XzdSfkFukuan> fukuanList;
|
||||
|
||||
List<XzdSfkFapiao> fapiaoList;
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.dromara.xzd.paymentsReceipts.domain.bo;
|
||||
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFapiao;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFukuan;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkZonhefuwuFk;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
@ -10,6 +12,7 @@ import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 综合服务合同付款业务对象 xzd_sfk_zonhefuwu_fk
|
||||
@ -31,7 +34,7 @@ public class XzdSfkZonhefuwuFkBo extends BaseEntity {
|
||||
/**
|
||||
* 单据编码(带*,必填)
|
||||
*/
|
||||
@NotBlank(message = "单据编码(带*,必填)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "单据编码(带*,必填)不能为空", groups = {EditGroup.class })
|
||||
private String docCode;
|
||||
|
||||
/**
|
||||
@ -76,7 +79,7 @@ public class XzdSfkZonhefuwuFkBo extends BaseEntity {
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
private Long projectId;
|
||||
private Long project;
|
||||
|
||||
/**
|
||||
* 付款单位
|
||||
@ -172,6 +175,11 @@ public class XzdSfkZonhefuwuFkBo extends BaseEntity {
|
||||
*/
|
||||
private BigDecimal currentPaymentRatio;
|
||||
|
||||
/**
|
||||
* 累计进度支付占累计进度应付(%)
|
||||
*/
|
||||
private BigDecimal totalPaymentRatio;
|
||||
|
||||
/**
|
||||
* 累计支付占合同比例(%)
|
||||
*/
|
||||
@ -222,5 +230,9 @@ public class XzdSfkZonhefuwuFkBo extends BaseEntity {
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
List<XzdSfkFukuan> fukuanList;
|
||||
|
||||
List<XzdSfkFapiao> fapiaoList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package org.dromara.xzd.paymentsReceipts.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkCaigouFk;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
@ -8,12 +10,14 @@ import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFapiao;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFukuan;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -25,7 +29,7 @@ import java.util.Date;
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = XzdSfkCaigouFk.class)
|
||||
public class XzdSfkCaigouFkVo implements Serializable {
|
||||
public class XzdSfkCaigouFkVo extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -63,6 +67,7 @@ public class XzdSfkCaigouFkVo implements Serializable {
|
||||
@ExcelProperty(value = "合同编码", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "带=*,必填")
|
||||
private Long contractCode;
|
||||
private String contractCodeName;
|
||||
|
||||
/**
|
||||
* 合同名称
|
||||
@ -94,12 +99,14 @@ public class XzdSfkCaigouFkVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "项目")
|
||||
private Long project;
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 付款单位
|
||||
*/
|
||||
@ExcelProperty(value = "付款单位")
|
||||
private Long paymentUnit;
|
||||
private String paymentUnitName;
|
||||
|
||||
/**
|
||||
* 收款单位(带*,必填)
|
||||
@ -107,12 +114,14 @@ public class XzdSfkCaigouFkVo implements Serializable {
|
||||
@ExcelProperty(value = "收款单位", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "带=*,必填")
|
||||
private Long receiptUnit;
|
||||
private String receiptUnitName;
|
||||
|
||||
/**
|
||||
* 收款银行
|
||||
*/
|
||||
@ExcelProperty(value = "收款银行")
|
||||
private Long receiptBank;
|
||||
private String receiptBankName;
|
||||
|
||||
/**
|
||||
* 收款银行账号
|
||||
@ -128,10 +137,11 @@ public class XzdSfkCaigouFkVo implements Serializable {
|
||||
private String statCycle;
|
||||
|
||||
/**
|
||||
* 是否是研发类
|
||||
* 项目类型
|
||||
*/
|
||||
@ExcelProperty(value = "是否是研发类")
|
||||
private Long isYanfa;
|
||||
@ExcelProperty(value = "项目类型")
|
||||
private String projectType;
|
||||
|
||||
|
||||
/**
|
||||
* 税率(带*,必填)
|
||||
@ -279,4 +289,8 @@ public class XzdSfkCaigouFkVo implements Serializable {
|
||||
private String fileId;
|
||||
|
||||
|
||||
List<XzdSfkFukuan> fukuanList;
|
||||
|
||||
List<XzdSfkFapiao> fapiaoList;
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package org.dromara.xzd.paymentsReceipts.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFapiao;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFukuan;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkZonhefuwuFk;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
@ -13,7 +17,7 @@ import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -25,7 +29,7 @@ import java.util.Date;
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = XzdSfkZonhefuwuFk.class)
|
||||
public class XzdSfkZonhefuwuFkVo implements Serializable {
|
||||
public class XzdSfkZonhefuwuFkVo extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -63,6 +67,7 @@ public class XzdSfkZonhefuwuFkVo implements Serializable {
|
||||
@ExcelProperty(value = "合同编码", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "带=*,必填")
|
||||
private Long contractCode;
|
||||
private String contractCodeName;
|
||||
|
||||
/**
|
||||
* 合同名称
|
||||
@ -93,13 +98,15 @@ public class XzdSfkZonhefuwuFkVo implements Serializable {
|
||||
* 项目
|
||||
*/
|
||||
@ExcelProperty(value = "项目")
|
||||
private Long projectId;
|
||||
private Long project;
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 付款单位
|
||||
*/
|
||||
@ExcelProperty(value = "付款单位")
|
||||
private Long paymentUnit;
|
||||
private String paymentUnitName;
|
||||
|
||||
/**
|
||||
* 收款单位(带*,必填)
|
||||
@ -107,12 +114,14 @@ public class XzdSfkZonhefuwuFkVo implements Serializable {
|
||||
@ExcelProperty(value = "收款单位", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "带=*,必填")
|
||||
private Long receiptUnit;
|
||||
private String receiptUnitName;
|
||||
|
||||
/**
|
||||
* 收款银行
|
||||
*/
|
||||
@ExcelProperty(value = "收款银行")
|
||||
private Long receiptBank;
|
||||
private String receiptBankName;
|
||||
|
||||
/**
|
||||
* 收款银行账号
|
||||
@ -203,6 +212,11 @@ public class XzdSfkZonhefuwuFkVo implements Serializable {
|
||||
@ExcelDictFormat(readConverterExp = "%=")
|
||||
private BigDecimal totalProgressSettlementRatio;
|
||||
|
||||
/**
|
||||
* 累计进度支付占累计进度应付(%)
|
||||
*/
|
||||
private BigDecimal totalPaymentRatio;
|
||||
|
||||
/**
|
||||
* 本期进度支付占本期进度应付(%)
|
||||
*/
|
||||
@ -273,4 +287,8 @@ public class XzdSfkZonhefuwuFkVo implements Serializable {
|
||||
private String fileId;
|
||||
|
||||
|
||||
List<XzdSfkFukuan> fukuanList;
|
||||
|
||||
List<XzdSfkFapiao> fapiaoList;
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.xzd.paymentsReceipts.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -9,16 +10,30 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.utils.BatchNumberGenerator;
|
||||
import org.dromara.system.service.impl.SysOssServiceImpl;
|
||||
import org.dromara.xzd.comprehensive.service.IXzdCsContractInformationService;
|
||||
import org.dromara.xzd.contractManagement.purchaseManagement.service.IXzdPurchaseContractInformationService;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFapiao;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFukuan;
|
||||
import org.dromara.xzd.paymentsReceipts.service.IXzdSfkFapiaoService;
|
||||
import org.dromara.xzd.paymentsReceipts.service.IXzdSfkFukuanService;
|
||||
import org.dromara.xzd.service.IXzdCorrespondentList;
|
||||
import org.dromara.xzd.service.IXzdSupplierOpenBankService;
|
||||
import org.dromara.xzd.service.impl.XzdProjectServiceImpl;
|
||||
import org.dromara.xzd.service.impl.XzdSupplierInfoServiceImpl;
|
||||
import org.dromara.xzd.settlement.domain.XzdJsDeductionItems;
|
||||
import org.dromara.xzd.settlement.domain.vo.XzdJsZhfwJinduVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.bo.XzdSfkCaigouFkBo;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.vo.XzdSfkCaigouFkVo;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkCaigouFk;
|
||||
import org.dromara.xzd.paymentsReceipts.mapper.XzdSfkCaigouFkMapper;
|
||||
import org.dromara.xzd.paymentsReceipts.service.IXzdSfkCaigouFkService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 采购合同付款Service业务层处理
|
||||
@ -32,6 +47,23 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
|
||||
private final XzdSfkCaigouFkMapper baseMapper;
|
||||
|
||||
@Autowired
|
||||
private IXzdSfkFapiaoService fapiaoService;
|
||||
@Autowired
|
||||
private IXzdSfkFukuanService fukuanService;
|
||||
@Autowired
|
||||
private SysOssServiceImpl sysOssService;
|
||||
@Autowired
|
||||
private IXzdPurchaseContractInformationService purchaseContractInformationService;
|
||||
@Autowired
|
||||
private XzdProjectServiceImpl xzdProjectService;
|
||||
@Autowired
|
||||
private IXzdSupplierOpenBankService supplierOpenBankService;
|
||||
@Autowired
|
||||
private IXzdCorrespondentList iXzdCorrespondentList;
|
||||
@Autowired
|
||||
private XzdSupplierInfoServiceImpl xzdSupplierInfoService;
|
||||
|
||||
/**
|
||||
* 查询采购合同付款
|
||||
*
|
||||
@ -40,7 +72,10 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
*/
|
||||
@Override
|
||||
public XzdSfkCaigouFkVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
XzdSfkCaigouFkVo vo = baseMapper.selectVoById(id);
|
||||
getName(vo);
|
||||
getHttk(vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,6 +89,7 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
public TableDataInfo<XzdSfkCaigouFkVo> queryPageList(XzdSfkCaigouFkBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<XzdSfkCaigouFk> lqw = buildQueryWrapper(bo);
|
||||
Page<XzdSfkCaigouFkVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
result.getRecords().forEach(this::getName);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@ -66,7 +102,9 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
@Override
|
||||
public List<XzdSfkCaigouFkVo> queryList(XzdSfkCaigouFkBo bo) {
|
||||
LambdaQueryWrapper<XzdSfkCaigouFk> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
List<XzdSfkCaigouFkVo> vos = baseMapper.selectVoList(lqw);
|
||||
vos.forEach(this::getName);
|
||||
return vos;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<XzdSfkCaigouFk> buildQueryWrapper(XzdSfkCaigouFkBo bo) {
|
||||
@ -87,7 +125,7 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
lqw.eq(bo.getReceiptBank() != null, XzdSfkCaigouFk::getReceiptBank, bo.getReceiptBank());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getReceiptBankAccount()), XzdSfkCaigouFk::getReceiptBankAccount, bo.getReceiptBankAccount());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatCycle()), XzdSfkCaigouFk::getStatCycle, bo.getStatCycle());
|
||||
lqw.eq(bo.getIsYanfa() != null, XzdSfkCaigouFk::getIsYanfa, bo.getIsYanfa());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProjectType()), XzdSfkCaigouFk::getProjectType, bo.getProjectType());
|
||||
lqw.eq(bo.getTaxRate() != null, XzdSfkCaigouFk::getTaxRate, bo.getTaxRate());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProjectCategory()), XzdSfkCaigouFk::getProjectCategory, bo.getProjectCategory());
|
||||
lqw.eq(bo.getCurrentProgressPayment() != null, XzdSfkCaigouFk::getCurrentProgressPayment, bo.getCurrentProgressPayment());
|
||||
@ -120,13 +158,26 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(XzdSfkCaigouFkBo bo) {
|
||||
XzdSfkCaigouFk add = MapstructUtils.convert(bo, XzdSfkCaigouFk.class);
|
||||
validEntityBeforeSave(add);
|
||||
String banBen = BatchNumberGenerator.generateBatchNumber("SFKCGFK-");
|
||||
add.setDocCode(banBen);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
if (bo.getFapiaoList() == null || bo.getFapiaoList().isEmpty()) {
|
||||
throw new ServiceException("发票信息不能为空");
|
||||
}
|
||||
bo.getFapiaoList().forEach(item -> {item.setMainDocumentId(add.getId());});
|
||||
fapiaoService.saveBatch(bo.getFapiaoList());
|
||||
if (bo.getFukuanList() == null || bo.getFukuanList().isEmpty()) {
|
||||
throw new ServiceException("付款信息不能为空");
|
||||
}
|
||||
bo.getFukuanList().forEach(item -> {item.setMainDocumentId(add.getId());});
|
||||
fukuanService.saveBatch(bo.getFukuanList());
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -137,9 +188,22 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(XzdSfkCaigouFkBo bo) {
|
||||
XzdSfkCaigouFk update = MapstructUtils.convert(bo, XzdSfkCaigouFk.class);
|
||||
validEntityBeforeSave(update);
|
||||
fapiaoService.remove(new LambdaQueryWrapper<XzdSfkFapiao>().eq(XzdSfkFapiao::getMainDocumentId, bo.getId()));
|
||||
fukuanService.remove(new LambdaQueryWrapper<XzdSfkFukuan>().eq(XzdSfkFukuan::getMainDocumentId, bo.getId()));
|
||||
if (bo.getFapiaoList() == null || bo.getFapiaoList().isEmpty()) {
|
||||
throw new ServiceException("发票信息不能为空");
|
||||
}
|
||||
bo.getFapiaoList().forEach(item -> {item.setMainDocumentId(update.getId());});
|
||||
fapiaoService.saveBatch(bo.getFapiaoList());
|
||||
if (bo.getFukuanList() == null || bo.getFukuanList().isEmpty()) {
|
||||
throw new ServiceException("付款信息不能为空");
|
||||
}
|
||||
bo.getFukuanList().forEach(item -> {item.setMainDocumentId(update.getId());});
|
||||
fukuanService.saveBatch(bo.getFukuanList());
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@ -158,10 +222,81 @@ public class XzdSfkCaigouFkServiceImpl extends ServiceImpl<XzdSfkCaigouFkMapper,
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
List<Long> deleteIds = new ArrayList<>();
|
||||
for (Long id : ids) {
|
||||
XzdSfkCaigouFkVo vo = baseMapper.selectVoById(id);
|
||||
if (vo != null){
|
||||
//删除附件
|
||||
if (vo.getFileId()!= null && !vo.getFileId().isEmpty()){
|
||||
List<Long> list = Arrays.stream(vo.getFileId().split(",")).map(Long::valueOf).toList();
|
||||
deleteIds.addAll(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!deleteIds.isEmpty()) {
|
||||
sysOssService.deleteWithValidByIds(deleteIds, false);
|
||||
}
|
||||
fapiaoService.remove(new LambdaQueryWrapper<XzdSfkFapiao>().in(XzdSfkFapiao::getMainDocumentId, ids));
|
||||
fukuanService.remove(new LambdaQueryWrapper<XzdSfkFukuan>().in(XzdSfkFukuan::getMainDocumentId, ids));
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部分字段名称
|
||||
* @param item
|
||||
*/
|
||||
private void getName(XzdSfkCaigouFkVo item) {
|
||||
//项目名称
|
||||
if (item.getProject() != null){
|
||||
String projectName = xzdProjectService.queryNameById(item.getProject());
|
||||
if (projectName != null){
|
||||
item.setProjectName(projectName);
|
||||
}
|
||||
}
|
||||
//合同编码
|
||||
if (item.getContractCode() != null){
|
||||
String code = purchaseContractInformationService.queryCodeById(item.getContractCode());
|
||||
if (code != null){
|
||||
item.setContractCodeName(code);
|
||||
}
|
||||
}
|
||||
//收款单位(供应商名称)
|
||||
if (item.getReceiptUnit() != null){
|
||||
String unitName = xzdSupplierInfoService.queryNameById(item.getReceiptUnit());
|
||||
if (unitName != null){
|
||||
item.setReceiptUnitName(unitName);
|
||||
}
|
||||
}
|
||||
//付款单位(客户名称)
|
||||
if (item.getPaymentUnit()!= null){
|
||||
String byid = iXzdCorrespondentList.queryNameById(item.getPaymentUnit());
|
||||
if (byid!=null){
|
||||
item.setPaymentUnitName(byid);
|
||||
}
|
||||
}
|
||||
//收款银行
|
||||
if (item.getReceiptBank() != null){
|
||||
String bankName = supplierOpenBankService.queryNameById(item.getReceiptBank());
|
||||
if (bankName != null){
|
||||
item.setReceiptBankName(bankName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子项
|
||||
* @param vo
|
||||
*/
|
||||
private void getHttk(XzdSfkCaigouFkVo vo) {
|
||||
//发票信息
|
||||
vo.setFapiaoList(fapiaoService.getBaseMapper().selectList(new LambdaQueryWrapper<XzdSfkFapiao>().eq(XzdSfkFapiao::getMainDocumentId, vo.getId())));
|
||||
|
||||
//付款信息
|
||||
vo.setFukuanList(fukuanService.getBaseMapper().selectList(new LambdaQueryWrapper<XzdSfkFukuan>().eq(XzdSfkFukuan::getMainDocumentId, vo.getId())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.xzd.paymentsReceipts.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -9,16 +10,28 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.utils.BatchNumberGenerator;
|
||||
import org.dromara.system.service.impl.SysOssServiceImpl;
|
||||
import org.dromara.xzd.comprehensive.service.IXzdCsContractInformationService;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFapiao;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkFukuan;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.vo.XzdSfkCaigouFkVo;
|
||||
import org.dromara.xzd.paymentsReceipts.service.IXzdSfkFapiaoService;
|
||||
import org.dromara.xzd.paymentsReceipts.service.IXzdSfkFukuanService;
|
||||
import org.dromara.xzd.service.IXzdCorrespondentList;
|
||||
import org.dromara.xzd.service.IXzdSupplierOpenBankService;
|
||||
import org.dromara.xzd.service.impl.XzdProjectServiceImpl;
|
||||
import org.dromara.xzd.service.impl.XzdSupplierInfoServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.bo.XzdSfkZonhefuwuFkBo;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.vo.XzdSfkZonhefuwuFkVo;
|
||||
import org.dromara.xzd.paymentsReceipts.domain.XzdSfkZonhefuwuFk;
|
||||
import org.dromara.xzd.paymentsReceipts.mapper.XzdSfkZonhefuwuFkMapper;
|
||||
import org.dromara.xzd.paymentsReceipts.service.IXzdSfkZonhefuwuFkService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 综合服务合同付款Service业务层处理
|
||||
@ -32,6 +45,24 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
|
||||
private final XzdSfkZonhefuwuFkMapper baseMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IXzdSfkFapiaoService fapiaoService;
|
||||
@Autowired
|
||||
private IXzdSfkFukuanService fukuanService;
|
||||
@Autowired
|
||||
private SysOssServiceImpl sysOssService;
|
||||
@Autowired
|
||||
private IXzdCsContractInformationService csContractInformationService;
|
||||
@Autowired
|
||||
private XzdProjectServiceImpl xzdProjectService;
|
||||
@Autowired
|
||||
private IXzdSupplierOpenBankService supplierOpenBankService;
|
||||
@Autowired
|
||||
private IXzdCorrespondentList iXzdCorrespondentList;
|
||||
@Autowired
|
||||
private XzdSupplierInfoServiceImpl xzdSupplierInfoService;
|
||||
|
||||
/**
|
||||
* 查询综合服务合同付款
|
||||
*
|
||||
@ -40,7 +71,10 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
*/
|
||||
@Override
|
||||
public XzdSfkZonhefuwuFkVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
XzdSfkZonhefuwuFkVo vo = baseMapper.selectVoById(id);
|
||||
getName(vo);
|
||||
getHttk(vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,6 +88,7 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
public TableDataInfo<XzdSfkZonhefuwuFkVo> queryPageList(XzdSfkZonhefuwuFkBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<XzdSfkZonhefuwuFk> lqw = buildQueryWrapper(bo);
|
||||
Page<XzdSfkZonhefuwuFkVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
result.getRecords().forEach(this::getName);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@ -66,7 +101,9 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
@Override
|
||||
public List<XzdSfkZonhefuwuFkVo> queryList(XzdSfkZonhefuwuFkBo bo) {
|
||||
LambdaQueryWrapper<XzdSfkZonhefuwuFk> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
List<XzdSfkZonhefuwuFkVo> vos = baseMapper.selectVoList(lqw);
|
||||
vos.forEach(this::getName);
|
||||
return vos;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<XzdSfkZonhefuwuFk> buildQueryWrapper(XzdSfkZonhefuwuFkBo bo) {
|
||||
@ -81,7 +118,7 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
lqw.eq(bo.getPaymentProperty() != null, XzdSfkZonhefuwuFk::getPaymentProperty, bo.getPaymentProperty());
|
||||
lqw.eq(bo.getExpendContractAmount() != null, XzdSfkZonhefuwuFk::getExpendContractAmount, bo.getExpendContractAmount());
|
||||
lqw.eq(bo.getCurrentApproveAmount() != null, XzdSfkZonhefuwuFk::getCurrentApproveAmount, bo.getCurrentApproveAmount());
|
||||
lqw.eq(bo.getProjectId() != null, XzdSfkZonhefuwuFk::getProjectId, bo.getProjectId());
|
||||
lqw.eq(bo.getProject() != null, XzdSfkZonhefuwuFk::getProject, bo.getProject());
|
||||
lqw.eq(bo.getPaymentUnit() != null, XzdSfkZonhefuwuFk::getPaymentUnit, bo.getPaymentUnit());
|
||||
lqw.eq(bo.getReceiptUnit() != null, XzdSfkZonhefuwuFk::getReceiptUnit, bo.getReceiptUnit());
|
||||
lqw.eq(bo.getReceiptBank() != null, XzdSfkZonhefuwuFk::getReceiptBank, bo.getReceiptBank());
|
||||
@ -119,13 +156,26 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(XzdSfkZonhefuwuFkBo bo) {
|
||||
XzdSfkZonhefuwuFk add = MapstructUtils.convert(bo, XzdSfkZonhefuwuFk.class);
|
||||
validEntityBeforeSave(add);
|
||||
String banBen = BatchNumberGenerator.generateBatchNumber("SFKZHFWFK-");
|
||||
add.setDocCode(banBen);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
if (bo.getFapiaoList() == null || bo.getFapiaoList().isEmpty()) {
|
||||
throw new ServiceException("发票信息不能为空");
|
||||
}
|
||||
bo.getFapiaoList().forEach(item -> {item.setMainDocumentId(add.getId());});
|
||||
fapiaoService.saveBatch(bo.getFapiaoList());
|
||||
if (bo.getFukuanList() == null || bo.getFukuanList().isEmpty()) {
|
||||
throw new ServiceException("付款信息不能为空");
|
||||
}
|
||||
bo.getFukuanList().forEach(item -> {item.setMainDocumentId(add.getId());});
|
||||
fukuanService.saveBatch(bo.getFukuanList());
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -136,9 +186,22 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(XzdSfkZonhefuwuFkBo bo) {
|
||||
XzdSfkZonhefuwuFk update = MapstructUtils.convert(bo, XzdSfkZonhefuwuFk.class);
|
||||
validEntityBeforeSave(update);
|
||||
fapiaoService.remove(new LambdaQueryWrapper<XzdSfkFapiao>().eq(XzdSfkFapiao::getMainDocumentId, bo.getId()));
|
||||
fukuanService.remove(new LambdaQueryWrapper<XzdSfkFukuan>().eq(XzdSfkFukuan::getMainDocumentId, bo.getId()));
|
||||
if (bo.getFapiaoList() == null || bo.getFapiaoList().isEmpty()) {
|
||||
throw new ServiceException("发票信息不能为空");
|
||||
}
|
||||
bo.getFapiaoList().forEach(item -> {item.setMainDocumentId(update.getId());});
|
||||
fapiaoService.saveBatch(bo.getFapiaoList());
|
||||
if (bo.getFukuanList() == null || bo.getFukuanList().isEmpty()) {
|
||||
throw new ServiceException("付款信息不能为空");
|
||||
}
|
||||
bo.getFukuanList().forEach(item -> {item.setMainDocumentId(update.getId());});
|
||||
fukuanService.saveBatch(bo.getFukuanList());
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@ -157,10 +220,81 @@ public class XzdSfkZonhefuwuFkServiceImpl extends ServiceImpl<XzdSfkZonhefuwuFkM
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
List<Long> deleteIds = new ArrayList<>();
|
||||
for (Long id : ids) {
|
||||
XzdSfkZonhefuwuFkVo vo = baseMapper.selectVoById(id);
|
||||
if (vo != null){
|
||||
//删除附件
|
||||
if (vo.getFileId()!= null && !vo.getFileId().isEmpty()){
|
||||
List<Long> list = Arrays.stream(vo.getFileId().split(",")).map(Long::valueOf).toList();
|
||||
deleteIds.addAll(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!deleteIds.isEmpty()) {
|
||||
sysOssService.deleteWithValidByIds(deleteIds, false);
|
||||
}
|
||||
fapiaoService.remove(new LambdaQueryWrapper<XzdSfkFapiao>().in(XzdSfkFapiao::getMainDocumentId, ids));
|
||||
fukuanService.remove(new LambdaQueryWrapper<XzdSfkFukuan>().in(XzdSfkFukuan::getMainDocumentId, ids));
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部分字段名称
|
||||
* @param item
|
||||
*/
|
||||
private void getName(XzdSfkZonhefuwuFkVo item) {
|
||||
//项目名称
|
||||
if (item.getProject() != null){
|
||||
String projectName = xzdProjectService.queryNameById(item.getProject());
|
||||
if (projectName != null){
|
||||
item.setProjectName(projectName);
|
||||
}
|
||||
}
|
||||
//合同编码
|
||||
if (item.getContractCode() != null){
|
||||
String code = csContractInformationService.queryCodeById(item.getContractCode());
|
||||
if (code != null){
|
||||
item.setContractCodeName(code);
|
||||
}
|
||||
}
|
||||
//收款单位(供应商名称)
|
||||
if (item.getReceiptUnit() != null){
|
||||
String unitName = xzdSupplierInfoService.queryNameById(item.getReceiptUnit());
|
||||
if (unitName != null){
|
||||
item.setReceiptUnitName(unitName);
|
||||
}
|
||||
}
|
||||
//付款单位(客户名称)
|
||||
if (item.getPaymentUnit()!= null){
|
||||
String byid = iXzdCorrespondentList.queryNameById(item.getPaymentUnit());
|
||||
if (byid!=null){
|
||||
item.setPaymentUnitName(byid);
|
||||
}
|
||||
}
|
||||
//收款银行
|
||||
if (item.getReceiptBank() != null){
|
||||
String bankName = supplierOpenBankService.queryNameById(item.getReceiptBank());
|
||||
if (bankName != null){
|
||||
item.setReceiptBankName(bankName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子项
|
||||
* @param vo
|
||||
*/
|
||||
private void getHttk(XzdSfkZonhefuwuFkVo vo) {
|
||||
//发票信息
|
||||
vo.setFapiaoList(fapiaoService.getBaseMapper().selectList(new LambdaQueryWrapper<XzdSfkFapiao>().eq(XzdSfkFapiao::getMainDocumentId, vo.getId())));
|
||||
|
||||
//付款信息
|
||||
vo.setFukuanList(fukuanService.getBaseMapper().selectList(new LambdaQueryWrapper<XzdSfkFukuan>().eq(XzdSfkFukuan::getMainDocumentId, vo.getId())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,4 +68,7 @@ public interface IXzdSupplierOpenBankService extends IService<XzdSupplierOpenBan
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
String queryNameById(Long id);
|
||||
|
||||
}
|
||||
|
||||
@ -147,4 +147,9 @@ public class XzdSupplierOpenBankServiceImpl extends ServiceImpl<XzdSupplierOpenB
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryNameById(Long id) {
|
||||
return baseMapper.selectVoById(id).getOpenBank();
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@ public class XzdJsZhfwJinduVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "合同编码")
|
||||
private Long contractCode;
|
||||
private String contractCodeCode;
|
||||
|
||||
/**
|
||||
* 合同名称
|
||||
@ -100,12 +101,14 @@ public class XzdJsZhfwJinduVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "项目")
|
||||
private Long project;
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 结算单位
|
||||
*/
|
||||
@ExcelProperty(value = "结算单位")
|
||||
private Long settlementUnit;
|
||||
private String settlementUnitName;
|
||||
|
||||
/**
|
||||
* 合同金额
|
||||
|
||||
@ -31,6 +31,7 @@ import org.dromara.xzd.settlement.domain.vo.XzdJsCgJungonEditVo;
|
||||
import org.dromara.xzd.settlement.domain.XzdJsCgJungonEdit;
|
||||
import org.dromara.xzd.settlement.mapper.XzdJsCgJungonEditMapper;
|
||||
import org.dromara.xzd.settlement.service.IXzdJsCgJungonEditService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -134,6 +135,7 @@ public class XzdJsCgJungonEditServiceImpl extends ServiceImpl<XzdJsCgJungonEditM
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(XzdJsCgJungonEditBo bo) {
|
||||
XzdJsCgJungonEdit add = MapstructUtils.convert(bo, XzdJsCgJungonEdit.class);
|
||||
validEntityBeforeSave(add);
|
||||
@ -163,6 +165,7 @@ public class XzdJsCgJungonEditServiceImpl extends ServiceImpl<XzdJsCgJungonEditM
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(XzdJsCgJungonEditBo bo) {
|
||||
XzdJsCgJungonEdit update = MapstructUtils.convert(bo, XzdJsCgJungonEdit.class);
|
||||
validEntityBeforeSave(update);
|
||||
@ -198,6 +201,7 @@ public class XzdJsCgJungonEditServiceImpl extends ServiceImpl<XzdJsCgJungonEditM
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.xzd.settlement.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -9,12 +10,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.utils.BatchNumberGenerator;
|
||||
import org.dromara.system.domain.vo.SysDeptVo;
|
||||
import org.dromara.system.service.impl.SysDeptServiceImpl;
|
||||
import org.dromara.system.service.impl.SysOssServiceImpl;
|
||||
import org.dromara.xzd.comprehensive.service.IXzdCsContractInformationService;
|
||||
import org.dromara.xzd.enums.XzdClassEnum;
|
||||
import org.dromara.xzd.service.IXzdCorrespondentList;
|
||||
import org.dromara.xzd.service.impl.XzdProjectServiceImpl;
|
||||
import org.dromara.xzd.settlement.domain.XzdJsDeductionItems;
|
||||
import org.dromara.xzd.settlement.domain.vo.XzdJsCgJungonEditVo;
|
||||
import org.dromara.xzd.settlement.domain.vo.XzdJsCgJungonVo;
|
||||
import org.dromara.xzd.settlement.service.IXzdJsDeductionItemsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -23,10 +29,9 @@ import org.dromara.xzd.settlement.domain.vo.XzdJsZhfwJinduVo;
|
||||
import org.dromara.xzd.settlement.domain.XzdJsZhfwJindu;
|
||||
import org.dromara.xzd.settlement.mapper.XzdJsZhfwJinduMapper;
|
||||
import org.dromara.xzd.settlement.service.IXzdJsZhfwJinduService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 综合服务合同进度结算Service业务层处理
|
||||
@ -46,14 +51,16 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
private SysOssServiceImpl sysOssService;
|
||||
|
||||
@Autowired
|
||||
private SysDeptServiceImpl sysDeptService;
|
||||
|
||||
private IXzdCsContractInformationService csContractInformationService;
|
||||
@Autowired
|
||||
private XzdProjectServiceImpl xzdProjectService;
|
||||
|
||||
@Autowired
|
||||
private IXzdJsDeductionItemsService deductionItemsService;
|
||||
|
||||
@Autowired
|
||||
private IXzdCorrespondentList iXzdCorrespondentList;
|
||||
|
||||
/**
|
||||
* 查询综合服务合同进度结算
|
||||
*
|
||||
@ -62,7 +69,10 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
*/
|
||||
@Override
|
||||
public XzdJsZhfwJinduVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
XzdJsZhfwJinduVo vo = baseMapper.selectVoById(id);
|
||||
getName(vo);
|
||||
getHttk(vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,6 +86,7 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
public TableDataInfo<XzdJsZhfwJinduVo> queryPageList(XzdJsZhfwJinduBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<XzdJsZhfwJindu> lqw = buildQueryWrapper(bo);
|
||||
Page<XzdJsZhfwJinduVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
result.getRecords().forEach(this::getName);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@ -88,7 +99,9 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
@Override
|
||||
public List<XzdJsZhfwJinduVo> queryList(XzdJsZhfwJinduBo bo) {
|
||||
LambdaQueryWrapper<XzdJsZhfwJindu> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
List<XzdJsZhfwJinduVo> vos = baseMapper.selectVoList(lqw);
|
||||
vos.forEach(this::getName);
|
||||
return vos;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<XzdJsZhfwJindu> buildQueryWrapper(XzdJsZhfwJinduBo bo) {
|
||||
@ -129,13 +142,27 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(XzdJsZhfwJinduBo bo) {
|
||||
XzdJsZhfwJindu add = MapstructUtils.convert(bo, XzdJsZhfwJindu.class);
|
||||
validEntityBeforeSave(add);
|
||||
String banBen = BatchNumberGenerator.generateBatchNumber("JSZHFWJD-");
|
||||
add.setDocCode(banBen);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
|
||||
String tableName = XzdClassEnum.JS_ZHFW_JINDU.getClassName();
|
||||
if (bo.getKkyjlx() == null || bo.getKkyjlx().isEmpty()) {
|
||||
throw new ServiceException("扣款与奖励项不能为空");
|
||||
}
|
||||
//合同条款-扣款与奖励项
|
||||
for (XzdJsDeductionItems kkyjlx : bo.getKkyjlx()) {
|
||||
kkyjlx.setTableName(tableName);
|
||||
kkyjlx.setMainDocId(add.getId());
|
||||
}
|
||||
deductionItemsService.saveBatch(bo.getKkyjlx());
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -146,9 +173,24 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(XzdJsZhfwJinduBo bo) {
|
||||
XzdJsZhfwJindu update = MapstructUtils.convert(bo, XzdJsZhfwJindu.class);
|
||||
validEntityBeforeSave(update);
|
||||
//删除奖励与扣款对应数据
|
||||
deductionItemsService.remove(new LambdaQueryWrapper<XzdJsDeductionItems>().eq(XzdJsDeductionItems::getMainDocId, update.getId()));
|
||||
//生成奖励与扣款数据
|
||||
String tableName = XzdClassEnum.JS_ZHFW_JINDU.getClassName();
|
||||
if (bo.getKkyjlx() == null || bo.getKkyjlx().isEmpty()) {
|
||||
throw new ServiceException("扣款与奖励项不能为空");
|
||||
}
|
||||
//合同条款-扣款与奖励项
|
||||
for (XzdJsDeductionItems kkyjlx : bo.getKkyjlx()) {
|
||||
kkyjlx.setTableName(tableName);
|
||||
kkyjlx.setMainDocId(update.getId());
|
||||
}
|
||||
//新增奖励与扣款数据
|
||||
deductionItemsService.saveBatch(bo.getKkyjlx());
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@ -167,10 +209,26 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
List<Long> deleteIds = new ArrayList<>();
|
||||
for (Long id : ids) {
|
||||
XzdJsZhfwJinduVo vo = baseMapper.selectVoById(id);
|
||||
if (vo != null){
|
||||
//删除附件
|
||||
if (vo.getFileId()!= null && !vo.getFileId().isEmpty()){
|
||||
List<Long> list = Arrays.stream(vo.getFileId().split(",")).map(Long::valueOf).toList();
|
||||
deleteIds.addAll(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!deleteIds.isEmpty()) {
|
||||
sysOssService.deleteWithValidByIds(deleteIds, false);
|
||||
}
|
||||
deductionItemsService.remove(new LambdaQueryWrapper<XzdJsDeductionItems>().in(XzdJsDeductionItems::getMainDocId, ids));
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@ -179,22 +237,29 @@ public class XzdJsZhfwJinduServiceImpl extends ServiceImpl<XzdJsZhfwJinduMapper,
|
||||
* 获取部分字段名称
|
||||
* @param item
|
||||
*/
|
||||
// private void getName(XzdJsZhfwJinduVo item) {
|
||||
// //项目名称
|
||||
// if (item.getProjectId() != null){
|
||||
// String projectName = xzdProjectService.queryNameById(item.getProjectId());
|
||||
// if (projectName != null){
|
||||
// item.setProjectName(projectName);
|
||||
// }
|
||||
// }
|
||||
// //部门名称
|
||||
// if (item.getDefaultFinanceOrg() != null){
|
||||
// SysDeptVo sysDeptVo = sysDeptService.selectDeptById(item.getDefaultFinanceOrg());
|
||||
// if (sysDeptVo != null){
|
||||
// item.setDefaultFinanceOrgName(sysDeptVo.getDeptName());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
private void getName(XzdJsZhfwJinduVo item) {
|
||||
//项目名称
|
||||
if (item.getProject() != null){
|
||||
String projectName = xzdProjectService.queryNameById(item.getProject());
|
||||
if (projectName != null){
|
||||
item.setProjectName(projectName);
|
||||
}
|
||||
}
|
||||
//合同编码
|
||||
if (item.getContractCode() != null){
|
||||
String code = csContractInformationService.queryCodeById(item.getContractCode());
|
||||
if (code != null){
|
||||
item.setContractCodeCode(code);
|
||||
}
|
||||
}
|
||||
//结算单位(客户信息列表)
|
||||
if (item.getSettlementUnit() != null){
|
||||
String byid = iXzdCorrespondentList.queryNameById(item.getSettlementUnit());
|
||||
if (byid!=null){
|
||||
item.setSettlementUnitName(byid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扣款与奖励项
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.project.mapper.BusProjectDeptMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.quality.mapper.QltFileFolderMapper">
|
||||
|
||||
|
||||
<update id="batchUpdateChildPaths">
|
||||
UPDATE hse_file_folder
|
||||
SET
|
||||
path = REPLACE(path, #{oldPath}, #{newPath}),
|
||||
level = level + #{levelDiff},
|
||||
update_time = NOW()
|
||||
WHERE
|
||||
path LIKE CONCAT(#{oldPath}, '%')
|
||||
AND id != #{parentId}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user