Commit 25868f991973f3f4a76c34e523ab7268d2916b78

Authored by 房远帅
1 parent c7359bb3

楚江ERP:撤销单-增加撤销总数量及按钮展示权限

... ... @@ -269,7 +269,7 @@ public class GetPurchaseOrderInfoBo extends BaseBo<PurchaseOrderInfo> {
269 269 /**
270 270 * 是否展示审核按钮(非持久化字段)
271 271 */
272   - @TableField(exist = false)
  272 + @ApiModelProperty("是否展示审核按钮")
273 273 private Boolean showExamine;
274 274
275 275
... ...
... ... @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.bo.order;
3 3 import com.fasterxml.jackson.annotation.JsonFormat;
4 4 import com.lframework.starter.common.constants.StringPool;
5 5 import com.lframework.starter.web.core.bo.BaseBo;
  6 +
  7 +import java.math.BigDecimal;
6 8 import java.time.LocalDate;
7 9 import java.util.List;
8 10 import com.lframework.xingyun.sc.entity.PurchaseOrderRevoke;
... ... @@ -96,12 +98,36 @@ public class GetPurchaseOrderRevokeBo extends BaseBo<PurchaseOrderRevoke> {
96 98 private String confirmationVoucherFileName;
97 99
98 100 /**
  101 + * 原总数量
  102 + */
  103 + @ApiModelProperty("原总数量")
  104 + private BigDecimal totalQuantity;
  105 +
  106 + /**
  107 + * 撤销总数量
  108 + */
  109 + @ApiModelProperty("撤销总数量")
  110 + private BigDecimal totalRevokeQuantity;
  111 +
  112 + /**
99 113 * 创建人(制单人)
100 114 */
101 115 @ApiModelProperty("创建人")
102 116 private String createBy;
103 117
104 118 /**
  119 + * 是否为撤销单创建人
  120 + */
  121 + @ApiModelProperty("创建人")
  122 + private boolean revokeCreateBy;
  123 +
  124 + /**
  125 + * 是否展示审核按钮(非持久化字段)
  126 + */
  127 + @ApiModelProperty("是否展示审核按钮")
  128 + private Boolean showExamine;
  129 +
  130 + /**
105 131 * 订货单撤销表物料行
106 132 */
107 133 @ApiModelProperty("订货单撤销表物料行")
... ...
... ... @@ -2,12 +2,15 @@ package com.lframework.xingyun.sc.controller.order;
2 2
3 3 import com.lframework.starter.common.utils.StringUtil;
4 4 import com.lframework.starter.web.core.annotations.security.HasPermission;
  5 +import com.lframework.starter.web.core.components.security.SecurityUtil;
5 6 import com.lframework.starter.web.core.controller.DefaultBaseController;
6 7 import com.lframework.starter.web.core.utils.PageResultUtil;
7 8 import com.lframework.starter.web.core.components.resp.PageResult;
8 9 import com.lframework.starter.web.core.components.resp.InvokeResult;
9 10 import javax.annotation.Resource;
10 11 import javax.validation.constraints.NotBlank;
  12 +
  13 +import com.lframework.xingyun.sc.bo.order.GetPurchaseOrderInfoBo;
11 14 import com.lframework.xingyun.sc.bo.order.GetPurchaseOrderRevokeBo;
12 15 import com.lframework.xingyun.sc.entity.*;
13 16 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
... ... @@ -64,7 +67,18 @@ public class PurchaseOrderRevokeController extends DefaultBaseController {
64 67 List<GetPurchaseOrderRevokeBo> results = null;
65 68
66 69 if (!CollectionUtil.isEmpty(datas)) {
67   - results = datas.stream().map(GetPurchaseOrderRevokeBo::new).collect(Collectors.toList());
  70 + String currentUserId = SecurityUtil.getCurrentUser().getId();
  71 +
  72 + results = datas.stream().map(purchaseOrderRevoke -> {
  73 + GetPurchaseOrderRevokeBo bo = new GetPurchaseOrderRevokeBo(purchaseOrderRevoke);
  74 + // 判断 createById 是否等于当前用户 ID
  75 + boolean isCreateBy = false;
  76 + if (currentUserId.equals(purchaseOrderRevoke.getCreateById())) {
  77 + isCreateBy = true;
  78 + }
  79 + bo.setRevokeCreateBy(isCreateBy);
  80 + return bo;
  81 + }).collect(Collectors.toList());
68 82 }
69 83
70 84 return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results));
... ...
... ... @@ -87,6 +87,16 @@ public class PurchaseOrderRevoke extends BaseEntity implements BaseDto {
87 87 private String confirmationVoucherFileName;
88 88
89 89 /**
  90 + * 原总数量
  91 + */
  92 + private BigDecimal totalQuantity;
  93 +
  94 + /**
  95 + * 撤销总数量
  96 + */
  97 + private BigDecimal totalRevokeQuantity;
  98 +
  99 + /**
90 100 * 撤销撤销数量总和(吨)(非持久化字段)
91 101 */
92 102 @TableField(exist = false)
... ... @@ -99,6 +109,12 @@ public class PurchaseOrderRevoke extends BaseEntity implements BaseDto {
99 109 private String userId;
100 110
101 111 /**
  112 + * 是否展示审核字段(非持久化字段)
  113 + */
  114 + @TableField(exist = false)
  115 + private boolean showExamine;
  116 +
  117 + /**
102 118 * 创建人ID
103 119 */
104 120 @TableField(fill = FieldFill.INSERT)
... ...
... ... @@ -234,6 +234,7 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
234 234 if (query.size() < query1.size()) {
235 235 b = false;
236 236 }
  237 + BigDecimal totalQuantity = BigDecimal.ZERO;
237 238 for (PurchaseOrderRevokeLine purchaseOrderRevokeLine : query) {
238 239 //原数量
239 240 BigDecimal quantity = purchaseOrderRevokeLine.getQuantity();
... ... @@ -247,9 +248,12 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
247 248 }
248 249 if (quantity != null) {
249 250 BigDecimal result = quantity.subtract(revokeQuantity);
  251 + totalQuantity = totalQuantity.add(result);
250 252 purchaseOrderLineService.updateQuantity(purchaseOrderRevokeLine.getPurchaseOrderLineId(), result);
251 253 }
252 254 }
  255 + //更新总数量
  256 + purchaseOrderInfoService.updateTotalQuantity(revoke.getPurchaseOrderId(), totalQuantity);
253 257 //更新订货单撤销状态(部分撤销、全部撤销)
254 258 if (b) {
255 259 //全部撤销
... ...
... ... @@ -37,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
37 37 import org.springframework.stereotype.Service;
38 38
39 39 import javax.annotation.Resource;
  40 +import java.math.BigDecimal;
40 41 import java.util.ArrayList;
41 42 import java.util.HashMap;
42 43 import java.util.List;
... ... @@ -373,6 +374,19 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
373 374 getBaseMapper().update(updateWrapper);
374 375 }
375 376
  377 + @OpLog(type = OtherOpLogType.class, name = "更新总数量,ID:{}", params = {"#id"})
  378 + @Transactional(rollbackFor = Exception.class)
  379 + @Override
  380 + public void updateTotalQuantity(String id, BigDecimal totalQuantity) {
  381 + if (StringUtils.isBlank(id) || totalQuantity == null) {
  382 + return;
  383 + }
  384 + LambdaUpdateWrapper<PurchaseOrderInfo> updateWrapper = Wrappers.lambdaUpdate(PurchaseOrderInfo.class)
  385 + .set(PurchaseOrderInfo::getTotalQuantity, totalQuantity)
  386 + .eq(PurchaseOrderInfo::getId, id);
  387 + getBaseMapper().update(updateWrapper);
  388 + }
  389 +
376 390 /**
377 391 * 更新规格变更状态
378 392 *
... ...
... ... @@ -3,7 +3,10 @@ package com.lframework.xingyun.sc.impl.order;
3 3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 4 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 5 import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.bpm.dto.FlowTaskDto;
  7 +import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
6 8 import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
  9 +import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
7 10 import com.lframework.starter.common.utils.CollectionUtil;
8 11 import com.lframework.starter.web.core.components.security.SecurityUtil;
9 12 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
... ... @@ -19,6 +22,7 @@ import com.lframework.starter.web.core.annotations.oplog.OpLog;
19 22 import com.lframework.starter.web.core.utils.PageHelperUtil;
20 23 import com.lframework.starter.common.utils.Assert;
21 24 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  25 +import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
22 26 import com.lframework.xingyun.sc.entity.PurchaseOrderRevoke;
23 27 import com.lframework.xingyun.sc.entity.PurchaseOrderRevokeLine;
24 28 import com.lframework.xingyun.sc.mappers.PurchaseOrderRevokeMapper;
... ... @@ -26,6 +30,7 @@ import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
26 30 import com.lframework.xingyun.sc.service.order.PurchaseOrderRevokeLineService;
27 31 import com.lframework.xingyun.sc.service.order.PurchaseOrderRevokeService;
28 32 import com.lframework.xingyun.sc.vo.order.*;
  33 +import org.apache.commons.collections.CollectionUtils;
29 34 import org.apache.commons.lang3.StringUtils;
30 35 import org.springframework.transaction.annotation.Transactional;
31 36 import org.springframework.stereotype.Service;
... ... @@ -35,6 +40,7 @@ import java.math.BigDecimal;
35 40 import java.math.RoundingMode;
36 41 import java.time.LocalDate;
37 42 import java.util.List;
  43 +import java.util.stream.Collectors;
38 44
39 45 @Service
40 46 public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOrderRevokeMapper, PurchaseOrderRevoke> implements PurchaseOrderRevokeService {
... ... @@ -46,7 +52,8 @@ public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOr
46 52 private PurchaseOrderInfoService purchaseOrderInfoService;
47 53 @Resource
48 54 private FlowInstanceWrapperService flowInstanceWrapperService;
49   -
  55 + @Resource
  56 + private FlowTaskWrapperMapper flowTaskWrapperMapper;
50 57
51 58 @Override
52 59 public PageResult<PurchaseOrderRevoke> query(Integer pageIndex, Integer pageSize, QueryPurchaseOrderRevokeVo vo) {
... ... @@ -56,6 +63,21 @@ public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOr
56 63
57 64 PageHelperUtil.startPage(pageIndex, pageSize);
58 65 List<PurchaseOrderRevoke> datas = this.query(vo);
  66 + if (CollectionUtils.isNotEmpty(datas)) {
  67 + // 获取当前人员的待办任务数据
  68 + List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  69 + if (CollectionUtils.isEmpty(flowTaskList)) {
  70 + return new PageResult<>();
  71 + }
  72 + List<String> ids = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
  73 + for (PurchaseOrderRevoke purchaseOrderRevoke : datas) {
  74 + if (ids.contains(purchaseOrderRevoke.getId())) {
  75 + purchaseOrderRevoke.setShowExamine(true);
  76 + } else {
  77 + purchaseOrderRevoke.setShowExamine(false);
  78 + }
  79 + }
  80 + }
59 81
60 82 return PageResultUtil.convert(new PageInfo<>(datas));
61 83 }
... ... @@ -108,6 +130,12 @@ public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOr
108 130 if (!StringUtil.isBlank(vo.getConfirmationVoucherFileName())) {
109 131 data.setConfirmationVoucherFileName(vo.getConfirmationVoucherFileName());
110 132 }
  133 + if (vo.getTotalQuantity() != null) {
  134 + data.setTotalQuantity(vo.getTotalQuantity());
  135 + }
  136 + if (vo.getTotalRevokeQuantity() != null) {
  137 + data.setTotalRevokeQuantity(vo.getTotalRevokeQuantity());
  138 + }
111 139
112 140 getBaseMapper().insert(data);
113 141
... ... @@ -176,6 +204,8 @@ public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOr
176 204 .set(PurchaseOrderRevoke::getRevokeReason, StringUtil.isBlank(vo.getRevokeReason()) ? null : vo.getRevokeReason())
177 205 .set(PurchaseOrderRevoke::getConfirmationVoucherFileId, StringUtil.isBlank(vo.getConfirmationVoucherFileId()) ? null : vo.getConfirmationVoucherFileId())
178 206 .set(PurchaseOrderRevoke::getConfirmationVoucherFileName, StringUtil.isBlank(vo.getConfirmationVoucherFileName()) ? null : vo.getConfirmationVoucherFileName())
  207 + .set(PurchaseOrderRevoke::getTotalQuantity, vo.getTotalQuantity() == null ? null : vo.getTotalQuantity())
  208 + .set(PurchaseOrderRevoke::getTotalRevokeQuantity, vo.getTotalRevokeQuantity() == null ? null : vo.getTotalRevokeQuantity())
179 209 .eq(PurchaseOrderRevoke::getId, vo.getId());
180 210
181 211 getBaseMapper().update(updateWrapper);
... ...
... ... @@ -6,6 +6,8 @@ import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
6 6 import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderInfoVo;
7 7 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderInfoVo;
8 8 import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderInfoVo;
  9 +
  10 +import java.math.BigDecimal;
9 11 import java.util.List;
10 12
11 13 /**
... ... @@ -90,6 +92,14 @@ public interface PurchaseOrderInfoService extends BaseMpService<PurchaseOrderInf
90 92 void updateRevokeStatus(String id, String status);
91 93
92 94 /**
  95 + * 更新总数量
  96 + *
  97 + * @param id 主键ID
  98 + * @param totalQuantity 总数量
  99 + */
  100 + void updateTotalQuantity(String id, BigDecimal totalQuantity);
  101 +
  102 + /**
93 103 * 更新规格变更状态
94 104 *
95 105 * @param id 主键ID
... ...
1 1 package com.lframework.xingyun.sc.vo.order;
2 2
3 3 import javax.validation.constraints.NotBlank;
  4 +import java.math.BigDecimal;
4 5 import java.time.LocalDate;
5 6 import com.lframework.starter.web.core.vo.BaseVo;
6 7 import com.lframework.xingyun.sc.entity.PurchaseOrderRevokeLine;
... ... @@ -94,4 +95,16 @@ public class CreatePurchaseOrderRevokeVo implements BaseVo, Serializable {
94 95 @ApiModelProperty("订货单撤销表物料行")
95 96 private List<PurchaseOrderRevokeLine> purchaseOrderRevokeLineList;
96 97
  98 + /**
  99 + * 原总数量
  100 + */
  101 + @ApiModelProperty("原总数量")
  102 + private BigDecimal totalQuantity;
  103 +
  104 + /**
  105 + * 撤销总数量
  106 + */
  107 + @ApiModelProperty("撤销总数量")
  108 + private BigDecimal totalRevokeQuantity;
  109 +
97 110 }
... ...
... ... @@ -2,6 +2,7 @@ package com.lframework.xingyun.sc.vo.order;
2 2
3 3 import lombok.Data;
4 4 import javax.validation.constraints.NotBlank;
  5 +import java.math.BigDecimal;
5 6 import java.time.LocalDate;
6 7 import com.lframework.starter.web.core.vo.BaseVo;
7 8 import com.lframework.starter.web.core.components.validation.TypeMismatch;
... ... @@ -57,4 +58,16 @@ public class UpdatePurchaseOrderRevokeVo implements BaseVo, Serializable {
57 58 @ApiModelProperty("订货单撤销单物料行")
58 59 List<UpdatePurchaseOrderRevokeLineVo> updatePurchaseOrderRevokeLineVoList;
59 60
  61 + /**
  62 + * 原总数量
  63 + */
  64 + @ApiModelProperty("原总数量")
  65 + private BigDecimal totalQuantity;
  66 +
  67 + /**
  68 + * 撤销总数量
  69 + */
  70 + @ApiModelProperty("撤销总数量")
  71 + private BigDecimal totalRevokeQuantity;
  72 +
60 73 }
... ...
... ... @@ -13,7 +13,8 @@
13 13 <result column="status" property="status"/>
14 14 <result column="revoke_reason" property="revokeReason"/>
15 15 <result column="confirmation_voucher_file_id" property="confirmationVoucherFileId"/>
16   - <result column="confirmation_voucher_file_name" property="confirmationVoucherFileName"/>
  16 + <result column="total_quantity" property="totalQuantity"/>
  17 + <result column="total_revoke_quantity" property="totalRevokeQuantity"/>
17 18 <result column="create_by_id" property="createById"/>
18 19 <result column="create_by" property="createBy"/>
19 20 <result column="update_by_id" property="updateById"/>
... ... @@ -36,6 +37,8 @@
36 37 tb.revoke_reason,
37 38 tb.confirmation_voucher_file_id,
38 39 tb.confirmation_voucher_file_name,
  40 + tb.total_quantity,
  41 + tb.total_revoke_quantity,
39 42 tb.create_by_id,
40 43 tb.create_by,
41 44 tb.update_by_id,
... ...