Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-07-08 17:12:44 +08:00
commit 8d20bb3e22
10 files changed
+298 -258

No files matched your search

@@ -1,244 +1,244 @@
package com.bsd.pjcloud.integrated.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.integrated.entity.MeetingBookingEntity;
import com.bsd.pjcloud.integrated.service.MeetingBookingService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.bsd.pjcloud.integrated.entity.MeetingRoomEntity;
import com.bsd.pjcloud.integrated.service.MeetingRoomService;
import com.bsd.pjcloud.flow.task.api.feign.RemoteFlowApiFlowService;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessInstanceParamDto;
import com.bsd.pjcloud.flow.task.entity.Process;
import com.bsd.pjcloud.integrated.constant.IntegratedFlowConstant;
import com.bsd.pjcloud.integrated.dto.flow.MeetingFlowDto;
import cn.hutool.core.bean.BeanUtil;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.exception.ServiceException;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Map;
import java.util.List;
import java.util.Objects;
import com.bsd.pjcloud.integrated.dto.meeting.MeetingBookingSaveDto;
import com.bsd.pjcloud.integrated.vo.meeting.MeetingBookingPageVo;
import java.util.HashMap;
/**
* 会议室预约
*
* @author zjf
* @date 2025-05-20 10:51:29
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/meetingBooking" )
@Tag(description = "meetingBooking" , name = "会议室预约管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MeetingBookingController {
private final MeetingBookingService meetingBookingService;
private final MeetingRoomService meetingRoomService;
private final RemoteFlowApiFlowService remoteFlowApiFlowService;
/**
* 分页查询
* @param page 分页对象
* @param meetingBooking 会议室预约
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('integrated_meetingBooking_view')")
public R<Page<MeetingBookingPageVo>> getMeetingBookingPage(@ParameterObject Page page, @ParameterObject MeetingBookingEntity meetingBooking) {
LambdaQueryWrapper<MeetingBookingEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(StrUtil.isNotBlank(meetingBooking.getTitle()), MeetingBookingEntity::getTitle, meetingBooking.getTitle());
Page<MeetingBookingEntity> entityPage = meetingBookingService.pageScope(page, wrapper);
// 批量查会议室名称,避免N+1
List<Long> roomIds = entityPage.getRecords().stream().map(MeetingBookingEntity::getRoomId).distinct().toList();
Map<Long, String> roomNameMap = new HashMap<>();
if (!roomIds.isEmpty()) {
List<MeetingRoomEntity> rooms = meetingRoomService.listByIds(roomIds);
for (MeetingRoomEntity room : rooms) {
roomNameMap.put(room.getId(), room.getRoomName());
}
}
// 转VO
List<MeetingBookingPageVo> voList = entityPage.getRecords().stream().map(e -> {
MeetingBookingPageVo vo = new MeetingBookingPageVo();
vo.setId(e.getId());
vo.setTitle(e.getTitle());
vo.setRoomId(e.getRoomId());
vo.setRoomName(roomNameMap.get(e.getRoomId()));
vo.setBookingDate(e.getBookingDate());
vo.setStartTime(e.getStartTime());
vo.setEndTime(e.getEndTime());
vo.setApplicantId(e.getApplicantId());
vo.setAssigneeName(e.getAssigneeName());
vo.setCheckStatus(e.getCheckStatus());
vo.setCheckReason(e.getCheckReason());
vo.setCreateTime(e.getCreateTime());
vo.setCreateBy(e.getCreateBy());
vo.setDescription(e.getDescription());
return vo;
}).toList();
Page<MeetingBookingPageVo> voPage = new Page<>(entityPage.getCurrent(), entityPage.getSize(), entityPage.getTotal());
voPage.setRecords(voList);
return R.ok(voPage);
}
/**
* 通过id查询会议室预约
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('integrated_meetingBooking_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(meetingBookingService.getById(id));
}
/**
* 新增会议室预约(PC端,逻辑与手机端一致)
* @param dto 预约参数
* @return R
*/
@Operation(summary = "新增会议室预约", description = "新增会议室预约")
@SysLog("新增会议室预约")
@PostMapping
@PreAuthorize("@pms.hasPermission('integrated_meetingBooking_add')")
@Transactional
public R save(@RequestBody MeetingBookingSaveDto dto) {
// 1. 参数转换
MeetingBookingEntity meetingBooking = new MeetingBookingEntity();
meetingBooking.setTitle(dto.getTitle());
meetingBooking.setRoomId(dto.getRoomId());
meetingBooking.setDescription(dto.getDescription());
meetingBooking.setBookingDate(LocalDate.parse(dto.getBookingDate()));
meetingBooking.setStartTime(LocalTime.parse(dto.getStartTime()));
meetingBooking.setEndTime(LocalTime.parse(dto.getEndTime()));
// 2. 验证会议室是否存在
MeetingRoomEntity room = meetingRoomService.getById(meetingBooking.getRoomId());
if (room == null) {
return R.failed("会议室不存在");
}
// 3. 验证会议室状态
if (!YesNoEnum.NO.getCode().equals(room.getStatus())) {
return R.failed("会议室当前不可用");
}
// 4. 校验时间
LocalDate bookingDate = meetingBooking.getBookingDate();
LocalTime startTime = meetingBooking.getStartTime();
LocalTime endTime = meetingBooking.getEndTime();
if (startTime == null || endTime == null || bookingDate == null) {
return R.failed("预约日期和时间不能为空");
}
if (startTime.isAfter(endTime)) {
return R.failed("开始时间不能晚于结束时间");
}
LocalTime availableStart = LocalTime.of(8, 0);
LocalTime availableEnd = LocalTime.of(18, 0);
if (startTime.isBefore(availableStart) || endTime.isAfter(availableEnd)) {
return R.failed("预约时间必须在8:00-18:00之间");
}
// 5. 检查时间段是否已被预约
var existingBookings = meetingBookingService.list(
Wrappers.<MeetingBookingEntity>lambdaQuery()
.eq(MeetingBookingEntity::getRoomId, meetingBooking.getRoomId())
.eq(MeetingBookingEntity::getBookingDate, bookingDate)
.eq(MeetingBookingEntity::getCheckStatus, TaskCheckStatusEnum.RESULT.getCode())
);
for (MeetingBookingEntity booking : existingBookings) {
LocalTime bookingStart = booking.getStartTime();
LocalTime bookingEnd = booking.getEndTime();
if (!(endTime.compareTo(bookingStart) <= 0 || startTime.compareTo(bookingEnd) >= 0)) {
return R.failed("该时间段已被预约");
}
}
// 6. 设置预约人、部门
meetingBooking.setApplicantId(SecurityUtils.getUser().getId());
meetingBooking.setDeptId(SecurityUtils.getUser().getDeptId());
// 7. 发起流程
var processByBusinessKey = remoteFlowApiFlowService.getProcessByBusinessKey(IntegratedFlowConstant.INTEGRATED_MEETING_BOOKING);
if (!processByBusinessKey.isOk() || processByBusinessKey.getData() == null) {
throw new ServiceException("流程配置获取失败: " + processByBusinessKey.getMsg());
}
Process process = processByBusinessKey.getData();
MeetingFlowDto meetingFlowDto = new MeetingFlowDto();
meetingFlowDto.setRoomName(room.getRoomName());
meetingFlowDto.setApplicantName(SecurityUtils.getUser().getUsername());
meetingFlowDto.setMeetingTime(bookingDate + " " + startTime + "-" + endTime);
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(meetingFlowDto);
ProcessInstanceParamDto processInstanceParamDto = new ProcessInstanceParamDto();
processInstanceParamDto.setFlowId(process.getFlowId());
processInstanceParamDto.setParamMap(stringObjectMap);
var stringR = remoteFlowApiFlowService.startProcessInstance(processInstanceParamDto);
meetingBooking.setCheckStatus(TaskCheckStatusEnum.PADDING.getCode());
meetingBooking.setProcessInstanceId(stringR.getData());
boolean success = meetingBookingService.save(meetingBooking);
return R.ok(success);
}
/**
* 修改会议室预约
* @param meetingBooking 会议室预约
* @return R
*/
@Operation(summary = "修改会议室预约" , description = "修改会议室预约" )
@SysLog("修改会议室预约" )
@PutMapping
@PreAuthorize("@pms.hasPermission('integrated_meetingBooking_edit')" )
public R updateById(@RequestBody MeetingBookingEntity meetingBooking) {
return R.ok(meetingBookingService.updateById(meetingBooking));
}
/**
* 通过id删除会议室预约
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除会议室预约" , description = "通过id删除会议室预约" )
@SysLog("通过id删除会议室预约" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('integrated_meetingBooking_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(meetingBookingService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param meetingBooking 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('integrated_meetingBooking_export')" )
public List<MeetingBookingEntity> export(MeetingBookingEntity meetingBooking,Long[] ids) {
return meetingBookingService.list(Wrappers.lambdaQuery(meetingBooking).in(ArrayUtil.isNotEmpty(ids), MeetingBookingEntity::getId, ids));
}
}
//package com.bsd.pjcloud.integrated.controller;
//
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.core.util.ArrayUtil;
//import cn.hutool.core.collection.CollUtil;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.bsd.pjcloud.common.core.util.R;
//import com.bsd.pjcloud.common.log.annotation.SysLog;
//import com.bsd.pjcloud.common.security.util.SecurityUtils;
//import com.bsd.pjcloud.integrated.entity.MeetingBookingEntity;
//import com.bsd.pjcloud.integrated.service.MeetingBookingService;
//import org.springframework.security.access.prepost.PreAuthorize;
//import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
//import io.swagger.v3.oas.annotations.security.SecurityRequirement;
//import org.springdoc.core.annotations.ParameterObject;
//import org.springframework.http.HttpHeaders;
//import io.swagger.v3.oas.annotations.tags.Tag;
//import io.swagger.v3.oas.annotations.Operation;
//import lombok.RequiredArgsConstructor;
//import org.springframework.web.bind.annotation.*;
//import com.bsd.pjcloud.integrated.entity.MeetingRoomEntity;
//import com.bsd.pjcloud.integrated.service.MeetingRoomService;
//import com.bsd.pjcloud.flow.task.api.feign.RemoteFlowApiFlowService;
//import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
//import com.bsd.pjcloud.flow.task.dto.ProcessInstanceParamDto;
//import com.bsd.pjcloud.flow.task.entity.Process;
//import com.bsd.pjcloud.integrated.constant.IntegratedFlowConstant;
//import com.bsd.pjcloud.integrated.dto.flow.MeetingFlowDto;
//import cn.hutool.core.bean.BeanUtil;
//import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
//import com.bsd.pjcloud.common.core.exception.ServiceException;
//import org.springframework.transaction.annotation.Transactional;
//import java.time.LocalDate;
//import java.time.LocalTime;
//import java.util.Map;
//
//import java.util.List;
//import java.util.Objects;
//import com.bsd.pjcloud.integrated.dto.meeting.MeetingBookingSaveDto;
//import com.bsd.pjcloud.integrated.vo.meeting.MeetingBookingPageVo;
//import java.util.HashMap;
//
///**
// * 会议室预约
// *
// * @author zjf
// * @date 2025-05-20 10:51:29
// */
//@RestController
//@RequiredArgsConstructor
//@RequestMapping("/meetingBooking" )
//@Tag(description = "meetingBooking" , name = "会议室预约管理" )
//@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
//public class MeetingBookingController {
//
// private final MeetingBookingService meetingBookingService;
// private final MeetingRoomService meetingRoomService;
// private final RemoteFlowApiFlowService remoteFlowApiFlowService;
//
// /**
// * 分页查询
// * @param page 分页对象
// * @param meetingBooking 会议室预约
// * @return
// */
// @Operation(summary = "分页查询", description = "分页查询")
// @GetMapping("/page")
// @PreAuthorize("@pms.hasPermission('integrated_meetingBooking_view')")
// public R<Page<MeetingBookingPageVo>> getMeetingBookingPage(@ParameterObject Page page, @ParameterObject MeetingBookingEntity meetingBooking) {
// LambdaQueryWrapper<MeetingBookingEntity> wrapper = Wrappers.lambdaQuery();
// wrapper.eq(StrUtil.isNotBlank(meetingBooking.getTitle()), MeetingBookingEntity::getTitle, meetingBooking.getTitle());
// Page<MeetingBookingEntity> entityPage = meetingBookingService.pageScope(page, wrapper);
//
// // 批量查会议室名称,避免N+1
// List<Long> roomIds = entityPage.getRecords().stream().map(MeetingBookingEntity::getRoomId).distinct().toList();
// Map<Long, String> roomNameMap = new HashMap<>();
// if (!roomIds.isEmpty()) {
// List<MeetingRoomEntity> rooms = meetingRoomService.listByIds(roomIds);
// for (MeetingRoomEntity room : rooms) {
// roomNameMap.put(room.getId(), room.getRoomName());
// }
// }
//
// // 转VO
// List<MeetingBookingPageVo> voList = entityPage.getRecords().stream().map(e -> {
// MeetingBookingPageVo vo = new MeetingBookingPageVo();
// vo.setId(e.getId());
// vo.setTitle(e.getTitle());
// vo.setRoomId(e.getRoomId());
// vo.setRoomName(roomNameMap.get(e.getRoomId()));
// vo.setBookingDate(e.getBookingDate());
// vo.setStartTime(e.getStartTime());
// vo.setEndTime(e.getEndTime());
// vo.setApplicantId(e.getApplicantId());
// vo.setAssigneeName(e.getAssigneeName());
// vo.setCheckStatus(e.getCheckStatus());
// vo.setCheckReason(e.getCheckReason());
// vo.setCreateTime(e.getCreateTime());
// vo.setCreateBy(e.getCreateBy());
// vo.setDescription(e.getDescription());
// return vo;
// }).toList();
//
// Page<MeetingBookingPageVo> voPage = new Page<>(entityPage.getCurrent(), entityPage.getSize(), entityPage.getTotal());
// voPage.setRecords(voList);
// return R.ok(voPage);
// }
//
//
// /**
// * 通过id查询会议室预约
// * @param id id
// * @return R
// */
// @Operation(summary = "通过id查询" , description = "通过id查询" )
// @GetMapping("/{id}" )
// @PreAuthorize("@pms.hasPermission('integrated_meetingBooking_view')" )
// public R getById(@PathVariable("id" ) Long id) {
// return R.ok(meetingBookingService.getById(id));
// }
//
// /**
// * 新增会议室预约(PC端,逻辑与手机端一致)
// * @param dto 预约参数
// * @return R
// */
// @Operation(summary = "新增会议室预约", description = "新增会议室预约")
// @SysLog("新增会议室预约")
// @PostMapping
// @PreAuthorize("@pms.hasPermission('integrated_meetingBooking_add')")
// @Transactional
// public R save(@RequestBody MeetingBookingSaveDto dto) {
// // 1. 参数转换
// MeetingBookingEntity meetingBooking = new MeetingBookingEntity();
// meetingBooking.setTitle(dto.getTitle());
// meetingBooking.setRoomId(dto.getRoomId());
// meetingBooking.setDescription(dto.getDescription());
// meetingBooking.setBookingDate(LocalDate.parse(dto.getBookingDate()));
// meetingBooking.setStartTime(LocalTime.parse(dto.getStartTime()));
// meetingBooking.setEndTime(LocalTime.parse(dto.getEndTime()));
// // 2. 验证会议室是否存在
// MeetingRoomEntity room = meetingRoomService.getById(meetingBooking.getRoomId());
// if (room == null) {
// return R.failed("会议室不存在");
// }
// // 3. 验证会议室状态
// if (!YesNoEnum.NO.getCode().equals(room.getStatus())) {
// return R.failed("会议室当前不可用");
// }
// // 4. 校验时间
// LocalDate bookingDate = meetingBooking.getBookingDate();
// LocalTime startTime = meetingBooking.getStartTime();
// LocalTime endTime = meetingBooking.getEndTime();
// if (startTime == null || endTime == null || bookingDate == null) {
// return R.failed("预约日期和时间不能为空");
// }
// if (startTime.isAfter(endTime)) {
// return R.failed("开始时间不能晚于结束时间");
// }
// LocalTime availableStart = LocalTime.of(8, 0);
// LocalTime availableEnd = LocalTime.of(18, 0);
// if (startTime.isBefore(availableStart) || endTime.isAfter(availableEnd)) {
// return R.failed("预约时间必须在8:00-18:00之间");
// }
// // 5. 检查时间段是否已被预约
// var existingBookings = meetingBookingService.list(
// Wrappers.<MeetingBookingEntity>lambdaQuery()
// .eq(MeetingBookingEntity::getRoomId, meetingBooking.getRoomId())
// .eq(MeetingBookingEntity::getBookingDate, bookingDate)
// .eq(MeetingBookingEntity::getCheckStatus, TaskCheckStatusEnum.RESULT.getCode())
// );
// for (MeetingBookingEntity booking : existingBookings) {
// LocalTime bookingStart = booking.getStartTime();
// LocalTime bookingEnd = booking.getEndTime();
// if (!(endTime.compareTo(bookingStart) <= 0 || startTime.compareTo(bookingEnd) >= 0)) {
// return R.failed("该时间段已被预约");
// }
// }
// // 6. 设置预约人、部门
// meetingBooking.setApplicantId(SecurityUtils.getUser().getId());
// meetingBooking.setDeptId(SecurityUtils.getUser().getDeptId());
// // 7. 发起流程
// var processByBusinessKey = remoteFlowApiFlowService.getProcessByBusinessKey(IntegratedFlowConstant.INTEGRATED_MEETING_BOOKING);
// if (!processByBusinessKey.isOk() || processByBusinessKey.getData() == null) {
// throw new ServiceException("流程配置获取失败: " + processByBusinessKey.getMsg());
// }
// Process process = processByBusinessKey.getData();
// MeetingFlowDto meetingFlowDto = new MeetingFlowDto();
// meetingFlowDto.setRoomName(room.getRoomName());
// meetingFlowDto.setApplicantName(SecurityUtils.getUser().getUsername());
// meetingFlowDto.setMeetingTime(bookingDate + " " + startTime + "-" + endTime);
// Map<String, Object> stringObjectMap = BeanUtil.beanToMap(meetingFlowDto);
// ProcessInstanceParamDto processInstanceParamDto = new ProcessInstanceParamDto();
// processInstanceParamDto.setFlowId(process.getFlowId());
// processInstanceParamDto.setParamMap(stringObjectMap);
// var stringR = remoteFlowApiFlowService.startProcessInstance(processInstanceParamDto);
// meetingBooking.setCheckStatus(TaskCheckStatusEnum.PADDING.getCode());
// meetingBooking.setProcessInstanceId(stringR.getData());
// boolean success = meetingBookingService.save(meetingBooking);
// return R.ok(success);
// }
//
// /**
// * 修改会议室预约
// * @param meetingBooking 会议室预约
// * @return R
// */
// @Operation(summary = "修改会议室预约" , description = "修改会议室预约" )
// @SysLog("修改会议室预约" )
// @PutMapping
// @PreAuthorize("@pms.hasPermission('integrated_meetingBooking_edit')" )
// public R updateById(@RequestBody MeetingBookingEntity meetingBooking) {
// return R.ok(meetingBookingService.updateById(meetingBooking));
// }
//
// /**
// * 通过id删除会议室预约
// * @param ids id列表
// * @return R
// */
// @Operation(summary = "通过id删除会议室预约" , description = "通过id删除会议室预约" )
// @SysLog("通过id删除会议室预约" )
// @DeleteMapping
// @PreAuthorize("@pms.hasPermission('integrated_meetingBooking_del')" )
// public R removeById(@RequestBody Long[] ids) {
// return R.ok(meetingBookingService.removeBatchByIds(CollUtil.toList(ids)));
// }
//
//
// /**
// * 导出excel 表格
// * @param meetingBooking 查询条件
// * @param ids 导出指定ID
// * @return excel 文件流
// */
// @ResponseExcel
// @GetMapping("/export")
// @PreAuthorize("@pms.hasPermission('integrated_meetingBooking_export')" )
// public List<MeetingBookingEntity> export(MeetingBookingEntity meetingBooking,Long[] ids) {
// return meetingBookingService.list(Wrappers.lambdaQuery(meetingBooking).in(ArrayUtil.isNotEmpty(ids), MeetingBookingEntity::getId, ids));
// }
//}
@@ -17,7 +17,8 @@ public enum WalletRechargeInvoiceStatusEnum {
BINDED("2", "已绑定充值"),
UNCHECKED("3", "未审核"),
CHECKED("4", "审核成功"),
CANCELLATION("5", "作废"),
FINANCE_CANCELLATION("5", "财务管理员作废"),
DEPT_CANCELLATION("6", "部门管理员作废"),
;
private final String code;
@@ -1,8 +1,7 @@
package com.bsd.pjcloud.wallet.api.dto.recharge;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
import lombok.Data;
import org.apache.commons.math3.optim.nonlinear.scalar.LineSearch;
import java.time.LocalDateTime;
import java.util.List;
@@ -11,7 +10,7 @@ import java.util.List;
* 充值记录绑定发票
*/
@Data
public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceVo {
public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceEntity {
/**
* 充值/扣款申请id
@@ -37,4 +36,6 @@ public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceVo {
* 审核时间
*/
private LocalDateTime[] processTimeList;
private Boolean isFindUserCheck = false;
}
@@ -8,4 +8,7 @@ public class WalletRechargeInvoiceVo extends WalletRechargeInvoiceEntity {
private String totalPriceCnStr;
private Boolean isCheckUser;
}
@@ -53,6 +53,7 @@ public class WalletRechargeApplyController {
@PostMapping("/save-topup")
@Operation(summary = "新增充值")
@Idempotent(expireTime = 3, info = "正在充值中,请勿重复操作")
public R comparePageJoin(@RequestBody WalletRechargeSaveTopupDto dto) {
walletRechargeApplyService.saveTopup(dto);
return R.ok();
@@ -68,6 +69,7 @@ public class WalletRechargeApplyController {
@SysLog("提交申请")
@GetMapping("/apply")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeApply_apply')")
@Idempotent(expireTime = 5, info = "正在申请中,请勿重复操作")
public R apply(@RequestParam Long id) {
walletRechargeApplyService.apply(id);
return R.ok(true);
@@ -95,6 +95,7 @@ public class WalletRechargeInvoiceController {
public R getWalletRechargeInvoicePage(@ParameterObject Page page, @ParameterObject WalletRechargeBindInvoiceDto dto) {
DataScope dataScope = DataScope.of();
dataScope.setScopeDeptName("apply_dept_id");
dto.setIsFindUserCheck(true);
return R.ok(walletRechargeInvoiceService.scopePageList(page, dto, dataScope));
}
@@ -3,9 +3,7 @@ package com.bsd.pjcloud.wallet.mapper.recharge;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargePackageDto;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargePackageEntity;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargePackageVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
@@ -193,9 +193,12 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
dto.setProcessInstanceIdList(List.of(detail.getProcessId()));
flowEngineService.stopProcessInstance(dto).getData();
}
// 如果有发票要删除一下
// 如果有发票要改一下状态
if (ObjectUtil.isNotEmpty(detail.getInvoiceId())) {
walletRechargeInvoiceService.removeById(detail.getInvoiceId());
WalletRechargeInvoiceEntity updateObj = new WalletRechargeInvoiceEntity();
updateObj.setId(detail.getInvoiceId());
updateObj.setStatus(WalletRechargeInvoiceStatusEnum.DEPT_CANCELLATION.getCode());
walletRechargeInvoiceService.updateById(updateObj);
}
// 删除申请记录
baseMapper.deleteById(v);
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
@@ -16,14 +17,17 @@ import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteFileService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
import com.bsd.pjcloud.common.data.tenant.TenantContextHolder;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.flow.task.api.feign.RemoteFlowEngineService;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.flow.task.dto.TaskDto;
import com.bsd.pjcloud.flow.task.dto.TaskParamDto;
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletRechargeInvoiceStatusEnum;
@@ -53,7 +57,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -100,6 +103,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
.set(WalletRechargeInvoiceEntity::getProcessStatus, null)
.set(WalletRechargeInvoiceEntity::getProcessTime, null)
.set(WalletRechargeInvoiceEntity::getStampPicUrl, null)
.set(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.FINANCE_CANCELLATION.getCode())
.eq(WalletRechargeInvoiceEntity::getId, id)
);
}
@@ -109,7 +113,9 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
*/
@Override
public Page<WalletRechargeInvoiceVo> scopePageList(Page page, WalletRechargeBindInvoiceDto dto, DataScope dataScope) {
return baseMapper.scopePageList(page, dto, dataScope);
Page<WalletRechargeInvoiceVo> pageList = baseMapper.scopePageList(page, dto, dataScope);
disposeList(pageList.getRecords(), dto);
return pageList;
}
/**
@@ -314,6 +320,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
if (isConsent) {
// 盖章
detail.setProcessStatus(TaskCheckStatusEnum.RESULT.getCode());
String stampPicUrl = stamp(detail);
if (ObjectUtil.isNotEmpty(stampPicUrl)) {
// 更新盖章图片
@@ -379,7 +386,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
return null;
}
// 审核成功才能开发票
if (ObjectUtil.notEqual(invoice.getProcessStatus(), TaskCheckStatusEnum.RESULT.getCode()) && false) {
if (ObjectUtil.notEqual(invoice.getProcessStatus(), TaskCheckStatusEnum.RESULT.getCode())) {
log.error("|{}|盖章失败,审核成功才能开发票,invoice:|{}|", TAG, JSONUtil.toJsonStr(invoice));
return null;
}
@@ -389,7 +396,6 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
}
// 开始盖章
String picUrl = String.format("%s%s", imageBaseUrl, invoice.getPicUrl());
File receiptStamp = FileUtil.file("image/receiptStamp.png");
// 发票底图宽高 3969 x 2154
int baseMapWidth = 3969, baseMapHeight = 2154;
// 盖章图片宽高
@@ -399,7 +405,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
// 读取底图
BufferedImage baseImage = ImageIO.read(new URL(picUrl));
// 读取盖章图片
BufferedImage stampImage = ImageIO.read(receiptStamp);
BufferedImage stampImage = ImageIO.read(ResourceUtil.getResource("image/receiptStamp.png"));
stampImage.getScaledInstance(stampWidth, stampHeight, Image.SCALE_SMOOTH);
// 创建新的图像上下文
Graphics2D g2d = baseImage.createGraphics();
@@ -422,6 +428,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
String url = (String) data.get("url");
return url;
} catch (IOException e) {
e.printStackTrace();
log.error("|{}|盖章失败,IO异常,invoice:|{}|error:|{}|", TAG, JSONUtil.toJsonStr(invoice), e.getMessage());
return null;
}
@@ -441,4 +448,25 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
.eq(WalletRechargeApplyEntity::getId, entity.getApplyId());
applyMapper.update(updateWrapper);
}
private void disposeList(List<WalletRechargeInvoiceVo> list, WalletRechargeBindInvoiceDto dto) {
if (ObjectUtil.isEmpty(list)) return;
// 审批流程
if (dto.getIsFindUserCheck()) {
List<String> processInstanceIds = list.stream().map(WalletRechargeInvoiceVo::getProcessId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isNotEmpty(processInstanceIds)) {
List<TaskDto> taskList = flowUtil.queryProcessInstanceList(SecurityUtils.getUser().getId().toString(), processInstanceIds);
if (ObjectUtil.isNotEmpty(taskList)) {
Map<String, TaskDto> taskMap = CollectionUtils.convertMap(taskList, TaskDto::getProcessInstanceId);
CollectionUtils.convertList(list, v -> {
TaskDto task = taskMap.get(v.getProcessId());
if (ObjectUtil.isNotEmpty(task)) {
v.setIsCheckUser(true);
}
return v;
});
}
}
}
}
}
@@ -32,7 +32,7 @@
<sql id="whereA">
a.del_flag = '0'
<if test="dto.status != null">
<if test="dto.status != null and dto.status != '' ">
and a.status = #{dto.status}
</if>
<if test="dto.processStatus != null and dto.processStatus != '' and dto.processStatus != 99 ">
@@ -44,6 +44,9 @@
<if test="dto.deptOrUser != null and dto.deptOrUser != '' ">
and a.dept_or_user like concat('%', #{dto.deptOrUser}, '%')
</if>
<if test="dto.remark != null and dto.remark != '' ">
and a.remark like concat('%', #{dto.remark}, '%')
</if>
<if test="dto.userIds != null and dto.userIds.size() != 0">
and a.apply_user_id in
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">