Commit 02679082 authored by zhengyi's avatar zhengyi

批量审批业务调整,并兼容批量批量修改后的批量审批提交

parent 0658f899
......@@ -31,7 +31,7 @@ public interface OrderFeeApplicationService extends IService<OrderFeeApplication
* @param createReqVO 创建信息
* @return 编号
*/
void createFeeBatchApplication(@Valid OrderFeeBatchApplicationCreateReqVO createReqVO) throws Exception;
void createFeeBatchApplication(@Valid OrderFeeBatchApplicationUpdateReqVO updateReqVO) throws Exception;
/**
* 更新订单费用申请
......
......@@ -151,7 +151,7 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
@Override
@Transactional(rollbackFor = Exception.class)
public void createFeeBatchApplication(OrderFeeBatchApplicationCreateReqVO createReqVO) {
public void createFeeBatchApplication(OrderFeeBatchApplicationUpdateReqVO createReqVO) {
// OrderDO orderDO = orderService.getById(createReqVO.getOrderId());
// if (orderDO.getAuditType() != 0) {
// throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
......@@ -168,14 +168,18 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
//查询订单信息
// 批量插入费用
List<OrderFeeApplicationCreateReqVO> baseVOList = createReqVO.getOrderFeeApplicationCreateReqVOList();
OrderDO orderDO = orderService.getById(createReqVO.getOrderId());
// 批量转换费用
List<OrderFeeApplicationUpdateReqVO> baseVOList = createReqVO.getOrderFeeApplicationCreateReqVOList();
List<OrderFeeApplicationDO> batchFeeList = new ArrayList<>();
for (OrderFeeApplicationCreateReqVO vo : baseVOList) {
for (OrderFeeApplicationUpdateReqVO vo : baseVOList) {
OrderFeeApplicationDO feeApplication = OrderFeeApplicationConvert.INSTANCE.convert(vo);
feeApplicationMapper.insert(feeApplication);
// if (Objects.isNull(feeApplication.getId())) {
// feeApplicationMapper.insert(feeApplication);
// }
batchFeeList.add(feeApplication);
}
......@@ -186,19 +190,29 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
//批量费用申请
orderApprovalDO.setType(expense_apply_BATCH.getValue());
orderApprovalDO.setStatus(ApprovalResultStatusEnum.processing.getValue());
Long bpmProcessId = orderApprovalService.applyAndCreate(orderApprovalDO, WorkFlowEmus.ORDER_BATCH_FREE_APPLY, createReqVO.getCopyUserId());
//创建审批流
OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, createReqVO.getOrderId());
orderApprovalDO.setStatus(ApprovalResultStatusEnum.processing.getValue());
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, OrderApprovalTypeResultEnum.expense_apply_batch_processing.getType(), OrderApprovalTypeResultEnum.expense_apply_batch_processing.getDesc());
orderApprovalService.save(orderApprovalDO);
//发起流程
String formId = bpmCreateServiceFactory.createBmp(SecurityFrameworkUtils.getLoginUserId(),
orderApprovalDO.getOrderApprovalId(), WorkFlowEmus.ORDER_BATCH_FREE_APPLY.getKey(), orderDO.getOrderNo(), createReqVO.getCopyUserId());
orderApprovalDO.setFormId(formId);
//更新费用列表对应的流程申请ID
for (OrderFeeApplicationDO feeApplication : batchFeeList) {
feeApplication.setBatchBpmBusinessId(String.valueOf(bpmProcessId));
feeApplication.setBatchBpmBusinessId(formId);
feeApplication.setStatus(ApprovalResultStatusEnum.processing.getValue());
feeApplicationMapper.updateById(feeApplication);
}
orderApprovalDO.setDetails(JSONObject.toJSONString(batchFeeList));
orderApprovalService.updateById(orderApprovalDO);
// Long bpmProcessId = orderApprovalService.applyAndCreate(orderApprovalDO, WorkFlowEmus.ORDER_BATCH_FREE_APPLY, createReqVO.getCopyUserId());
//创建审批流
// OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, createReqVO.getOrderId());
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, OrderApprovalTypeResultEnum.expense_apply_batch_processing.getType(), OrderApprovalTypeResultEnum.expense_apply_batch_processing.getDesc());
}
@Override
......@@ -455,11 +469,22 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
if (result == ApprovalResultStatusEnum.pass.getValue()) {
List<FeeDto> feeDtos = new ArrayList<>();
OrderBackVO order = orderQueryService.getOrder(orderApprovalDO.getOrderId());
LambdaQueryWrapper<OrderFeeApplicationDO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.eq(OrderFeeApplicationDO::getOrderId, orderApprovalDO.getOrderId());
lambdaQueryWrapper.eq(OrderFeeApplicationDO::getBatchBpmBusinessId, orderApprovalDO.getOrderApprovalId());
List<OrderFeeApplicationDO> batchFeeList = this.list(lambdaQueryWrapper);
List<OrderFeeApplicationDO> batchFeeList = null;
if (Objects.nonNull(orderApprovalDO.getDetails())){
batchFeeList = JSONObject.parseArray(JSONObject.toJSONString(orderApprovalDO.getDetails()), OrderFeeApplicationDO.class);
}else {
LambdaQueryWrapper<OrderFeeApplicationDO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.eq(OrderFeeApplicationDO::getOrderId, orderApprovalDO.getOrderId());
lambdaQueryWrapper.eq(OrderFeeApplicationDO::getBatchBpmBusinessId, orderApprovalDO.getOrderApprovalId());
batchFeeList = this.list(lambdaQueryWrapper);
}
for (OrderFeeApplicationDO feeApplicationDO : batchFeeList) {
feeApplicationDO.setStatus(result);
if (Objects.nonNull(feeApplicationDO.getId())){
feeApplicationMapper.updateById(feeApplicationDO);
}else {
feeApplicationMapper.insert(feeApplicationDO);
}
//生成应收
DictDataRespDTO dictDto = DictFrameworkUtils.getDictDataFromCache("receivable_fee_type", String.valueOf(feeApplicationDO.getFeeType()));
if (feeApplicationDO.getReceivableId() != null && feeApplicationDO.getReceivableId() > 0) {
......@@ -538,6 +563,14 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
@Override
public List<OrderFeeApplicationDO> getFeeApplicationListByOrderId(Long orderId) {
OrderApprovalDO approvalDO = orderApprovalService.getOne(new LambdaQueryWrapper<OrderApprovalDO>()
.eq(OrderApprovalDO::getOrderId, orderId)
.eq(OrderApprovalDO::getStatus, 1)
.orderByDesc(OrderApprovalDO::getOrderApprovalId).last("limit 1"));
if (Objects.nonNull(approvalDO) && approvalDO.getType() == 41 && Objects.nonNull(approvalDO.getDetails())) {
// 对于批量审批中的费用申请,直接返回审批中数据即可
return JSONObject.parseArray(JSONObject.toJSONString(approvalDO.getDetails()), OrderFeeApplicationDO.class);
}
List<OrderFeeApplicationDO> feeApplicationList = feeApplicationMapper.getFeeApplicationListByOrderId(orderId);
feeApplicationList.stream().forEach(item -> {
item.setApplicationAuthor(adminUserService.getUser(Long.valueOf(item.getCreator())).getUsername());
......@@ -552,7 +585,6 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
item.setReceiveFlag(0);
}
if (item.getStatus() == 1 && StringUtils.isNotBlank(item.getBpmProcessId())){
OrderApprovalDO approvalDO = orderApprovalService.getApproval(Long.valueOf(item.getBpmProcessId()));
if (Objects.nonNull(approvalDO) && Objects.nonNull(approvalDO.getDetails())){
OrderFeeApplicationDO feeApplicationDO = JSONObject.parseObject(approvalDO.getDetails(), OrderFeeApplicationDO.class);
BeanUtils.copyProperties(feeApplicationDO, item);
......
......@@ -11,7 +11,7 @@ import java.util.List;
@Data
@ToString(callSuper = true)
@ApiModel("管理后台 - 批量费用申请创建 Request VO")
@ApiModel("管理后台 - 批量费用申请创建或更新 Request VO")
public class OrderFeeBatchApplicationCreateReqVO {
@ApiModelProperty(value = "订单id", required = true)
@NotNull(message = "订单id不能为空")
......@@ -20,5 +20,5 @@ public class OrderFeeBatchApplicationCreateReqVO {
String[] copyUserId;
@ApiModelProperty(value = "批量费用")
@NotEmpty(message = "费用列表不能为空")
List<OrderFeeApplicationCreateReqVO> orderFeeApplicationCreateReqVOList;
List<OrderFeeApplicationUpdateReqVO> orderFeeApplicationCreateReqVOList;
}
package cn.iocoder.yudao.module.order.vo.orderFeeApplication;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@ToString(callSuper = true)
@ApiModel("管理后台 - 批量费用申请创建 Request VO")
public class OrderFeeBatchApplicationUpdateReqVO {
@ApiModelProperty(value = "订单id", required = true)
@NotNull(message = "订单id不能为空")
private Long orderId;
@ApiModelProperty(value = "抄送人userId")
String[] copyUserId;
@ApiModelProperty(value = "批量费用")
@NotEmpty(message = "费用列表不能为空")
List<OrderFeeApplicationUpdateReqVO> orderFeeApplicationCreateReqVOList;
}
......@@ -15,10 +15,7 @@ import cn.iocoder.yudao.module.order.enums.ApprovalResultStatusEnum;
import cn.iocoder.yudao.module.order.service.approval.OrderApprovalService;
import cn.iocoder.yudao.module.order.service.order.OrderFeeApplicationService;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import cn.iocoder.yudao.module.order.vo.orderFeeApplication.OrderFeeApplicationBackVO;
import cn.iocoder.yudao.module.order.vo.orderFeeApplication.OrderFeeApplicationQueryVO;
import cn.iocoder.yudao.module.order.vo.orderFeeApplication.OrderFeeApplicationUpdateReqVO;
import cn.iocoder.yudao.module.order.vo.orderFeeApplication.OrderFeeBatchApplicationCreateReqVO;
import cn.iocoder.yudao.module.order.vo.orderFeeApplication.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -85,7 +82,7 @@ public class OrderFeeApplicationController {
@PostMapping("/create/batch")
@ApiOperation("批量创建订单费用申请")
@Idempotent(timeout = 10)
public CommonResult<Boolean> createFeeBatchApplication(@Valid @RequestBody OrderFeeBatchApplicationCreateReqVO createReqVO) throws Exception {
public CommonResult<Boolean> createFeeBatchApplication(@Valid @RequestBody OrderFeeBatchApplicationUpdateReqVO createReqVO) throws Exception {
String redisKey = MessageFormat.format(ORDER_FEE_APPLICATION_KEY, createReqVO.getOrderId().toString());
Long count = redisHelper.incrBy(redisKey, 1);
if (count > 1){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment