Showing
5 changed files
with
142 additions
and
0 deletions
| ... | ... | @@ -2,6 +2,8 @@ package com.lframework.xingyun.sc.entity; |
| 2 | 2 | |
| 3 | 3 | import com.baomidou.mybatisplus.annotation.TableName; |
| 4 | 4 | import com.lframework.starter.web.core.dto.BaseDto; |
| 5 | + | |
| 6 | +import java.math.BigDecimal; | |
| 5 | 7 | import java.time.LocalDate; |
| 6 | 8 | import java.time.LocalDateTime; |
| 7 | 9 | import com.baomidou.mybatisplus.annotation.FieldFill; |
| ... | ... | @@ -85,6 +87,12 @@ public class PurchaseOrderRevoke extends BaseEntity implements BaseDto { |
| 85 | 87 | private String confirmationVoucherFileName; |
| 86 | 88 | |
| 87 | 89 | /** |
| 90 | + * 撤销撤销数量总和(吨)(非持久化字段) | |
| 91 | + */ | |
| 92 | + @TableField(exist = false) | |
| 93 | + private BigDecimal sumRevokeQuantity; | |
| 94 | + | |
| 95 | + /** | |
| 88 | 96 | * 创建人ID |
| 89 | 97 | */ |
| 90 | 98 | @TableField(fill = FieldFill.INSERT) | ... | ... |
| ... | ... | @@ -6,6 +6,9 @@ import com.lframework.starter.bpm.service.BusinessDataHandlerService; |
| 6 | 6 | import com.lframework.starter.web.core.components.redis.RedisHandler; |
| 7 | 7 | import com.lframework.starter.web.core.utils.JsonUtil; |
| 8 | 8 | import com.lframework.xingyun.sc.entity.CorePersonnelHistory; |
| 9 | +import com.lframework.xingyun.sc.entity.PurchaseOrderLine; | |
| 10 | +import com.lframework.xingyun.sc.entity.PurchaseOrderRevoke; | |
| 11 | +import com.lframework.xingyun.sc.entity.PurchaseOrderRevokeLine; | |
| 9 | 12 | import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; |
| 10 | 13 | import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService; |
| 11 | 14 | import com.lframework.xingyun.sc.service.customer.CorePersonnelHistoryService; |
| ... | ... | @@ -13,8 +16,13 @@ import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService; |
| 13 | 16 | import com.lframework.xingyun.sc.service.customer.CustomerCreditService; |
| 14 | 17 | import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService; |
| 15 | 18 | import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService; |
| 19 | +import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; | |
| 20 | +import com.lframework.xingyun.sc.service.order.PurchaseOrderRevokeLineService; | |
| 21 | +import com.lframework.xingyun.sc.service.order.PurchaseOrderRevokeService; | |
| 16 | 22 | import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelHistoryVo; |
| 17 | 23 | import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo; |
| 24 | +import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo; | |
| 25 | +import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderRevokeLineVo; | |
| 18 | 26 | import lombok.extern.slf4j.Slf4j; |
| 19 | 27 | import org.apache.commons.collections.CollectionUtils; |
| 20 | 28 | import org.apache.commons.collections4.MapUtils; |
| ... | ... | @@ -25,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 25 | 33 | import org.springframework.stereotype.Component; |
| 26 | 34 | |
| 27 | 35 | import javax.annotation.Resource; |
| 36 | +import java.math.BigDecimal; | |
| 28 | 37 | import java.util.ArrayList; |
| 29 | 38 | import java.util.List; |
| 30 | 39 | import java.util.Map; |
| ... | ... | @@ -48,6 +57,12 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic |
| 48 | 57 | private ContractDistributorStandardService contractDistributorStandardService; |
| 49 | 58 | @Resource |
| 50 | 59 | private PurchaseOrderInfoService purchaseOrderInfoService; |
| 60 | + @Resource | |
| 61 | + private PurchaseOrderLineService purchaseOrderLineService; | |
| 62 | + @Resource | |
| 63 | + private PurchaseOrderRevokeService purchaseOrderRevokeService; | |
| 64 | + @Resource | |
| 65 | + private PurchaseOrderRevokeLineService purchaseOrderRevokeLineService; | |
| 51 | 66 | |
| 52 | 67 | |
| 53 | 68 | /** |
| ... | ... | @@ -93,6 +108,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic |
| 93 | 108 | case "PURCHASE_ORDER": |
| 94 | 109 | handlePurchaseOrderData(flowStatus, businessId); |
| 95 | 110 | break; |
| 111 | + case "ORDER_CANCELLATION": | |
| 112 | + handlePurchaseOrderRevokeData(flowStatus, businessId); | |
| 113 | + break; | |
| 96 | 114 | default: |
| 97 | 115 | break; |
| 98 | 116 | } |
| ... | ... | @@ -158,6 +176,62 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic |
| 158 | 176 | } |
| 159 | 177 | |
| 160 | 178 | /** |
| 179 | + * 订货单撤销业务数据处理 | |
| 180 | + * | |
| 181 | + * @param businessId 业务ID | |
| 182 | + */ | |
| 183 | + private void handlePurchaseOrderRevokeData(String flowStatus, String businessId) { | |
| 184 | + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus) | |
| 185 | + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) { | |
| 186 | + purchaseOrderRevokeService.updateStatus(businessId, "PASS"); | |
| 187 | + //撤销单物料行 | |
| 188 | + QueryPurchaseOrderRevokeLineVo vo = new QueryPurchaseOrderRevokeLineVo(); | |
| 189 | + vo.setPurchaseOrderRevokeId(businessId); | |
| 190 | + List<PurchaseOrderRevokeLine> query = purchaseOrderRevokeLineService.query(vo); | |
| 191 | + PurchaseOrderRevoke revoke = purchaseOrderRevokeService.findById(businessId); | |
| 192 | + QueryPurchaseOrderLineVo vo1 = new QueryPurchaseOrderLineVo(); | |
| 193 | + vo1.setPurchaseOrderId(revoke.getPurchaseOrderId()); | |
| 194 | + List<PurchaseOrderLine> query1 = purchaseOrderLineService.query(vo1); | |
| 195 | + //更新订货单物料行数量 | |
| 196 | + if (CollectionUtils.isNotEmpty(query)) { | |
| 197 | + //是否为全部撤销 | |
| 198 | + Boolean b = true; | |
| 199 | + if (query.size() < query1.size()) { | |
| 200 | + b = false; | |
| 201 | + } | |
| 202 | + for (PurchaseOrderRevokeLine purchaseOrderRevokeLine : query) { | |
| 203 | + //原数量 | |
| 204 | + BigDecimal quantity = purchaseOrderRevokeLine.getQuantity(); | |
| 205 | + //撤销数量kg | |
| 206 | + BigDecimal revokeQuantity = purchaseOrderRevokeLine.getRevokeQuantity(); | |
| 207 | + if (revokeQuantity == null) { | |
| 208 | + revokeQuantity = BigDecimal.ZERO; | |
| 209 | + } | |
| 210 | + if (b && !(quantity != null && quantity.compareTo(revokeQuantity) == 0)) { | |
| 211 | + b = false; | |
| 212 | + } | |
| 213 | + if (quantity != null) { | |
| 214 | + BigDecimal result = quantity.subtract(revokeQuantity); | |
| 215 | + purchaseOrderLineService.updateQuantity(purchaseOrderRevokeLine.getPurchaseOrderLineId(), result); | |
| 216 | + } | |
| 217 | + } | |
| 218 | + //更新订货单撤销状态(部分撤销、全部撤销) | |
| 219 | + if (b) { | |
| 220 | + //全部撤销 | |
| 221 | + purchaseOrderInfoService.updateRevokeStatus(revoke.getPurchaseOrderId(), "ALL"); | |
| 222 | + } else { | |
| 223 | + //部分撤销 | |
| 224 | + purchaseOrderInfoService.updateRevokeStatus(revoke.getPurchaseOrderId(), "PARTIAL"); | |
| 225 | + } | |
| 226 | + } | |
| 227 | + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus) | |
| 228 | + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus) | |
| 229 | + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) { | |
| 230 | + purchaseOrderRevokeService.updateStatus(businessId, "REFUSE"); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + /** | |
| 161 | 235 | * 客户资信业务数据处理 |
| 162 | 236 | * |
| 163 | 237 | * @param businessId 业务ID | ... | ... |
| ... | ... | @@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils; |
| 28 | 28 | import org.springframework.transaction.annotation.Transactional; |
| 29 | 29 | import org.springframework.stereotype.Service; |
| 30 | 30 | |
| 31 | +import java.math.BigDecimal; | |
| 31 | 32 | import java.util.Collections; |
| 32 | 33 | import java.util.List; |
| 33 | 34 | |
| ... | ... | @@ -167,6 +168,26 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde |
| 167 | 168 | OpLogUtil.setExtra(vo); |
| 168 | 169 | } |
| 169 | 170 | |
| 171 | + @OpLog(type = OtherOpLogType.class, name = "修改订货单表物料行数量,ID:{}", params = {"#id"}) | |
| 172 | + @Transactional(rollbackFor = Exception.class) | |
| 173 | + @Override | |
| 174 | + public void updateQuantity(String id, BigDecimal quantity) { | |
| 175 | + | |
| 176 | + PurchaseOrderLine data = getBaseMapper().selectById(id); | |
| 177 | + if (ObjectUtil.isNull(data)) { | |
| 178 | + throw new DefaultClientException("订货单表物料行不存在!"); | |
| 179 | + } | |
| 180 | + | |
| 181 | + LambdaUpdateWrapper<PurchaseOrderLine> updateWrapper = Wrappers.lambdaUpdate(PurchaseOrderLine.class) | |
| 182 | + .set(PurchaseOrderLine::getQuantity, quantity) | |
| 183 | + .eq(PurchaseOrderLine::getId, id); | |
| 184 | + | |
| 185 | + getBaseMapper().update(updateWrapper); | |
| 186 | + | |
| 187 | + OpLogUtil.setVariable("id", data.getId()); | |
| 188 | + OpLogUtil.setExtra(id); | |
| 189 | + } | |
| 190 | + | |
| 170 | 191 | @OpLog(type = OtherOpLogType.class, name = "删除订货单表物料行,ID:{}", params = {"#id"}) |
| 171 | 192 | @Transactional(rollbackFor = Exception.class) |
| 172 | 193 | @Override | ... | ... |
| ... | ... | @@ -3,6 +3,7 @@ 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.service.FlowInstanceWrapperService; | |
| 6 | 7 | import com.lframework.starter.common.utils.CollectionUtil; |
| 7 | 8 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| 8 | 9 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| ... | ... | @@ -29,16 +30,21 @@ import org.springframework.transaction.annotation.Transactional; |
| 29 | 30 | import org.springframework.stereotype.Service; |
| 30 | 31 | |
| 31 | 32 | import javax.annotation.Resource; |
| 33 | +import java.math.BigDecimal; | |
| 34 | +import java.math.RoundingMode; | |
| 32 | 35 | import java.time.LocalDate; |
| 33 | 36 | import java.util.List; |
| 34 | 37 | |
| 35 | 38 | @Service |
| 36 | 39 | public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOrderRevokeMapper, PurchaseOrderRevoke> implements PurchaseOrderRevokeService { |
| 40 | + private static final String BPM_FLAG = "ORDER_CANCELLATION"; | |
| 37 | 41 | |
| 38 | 42 | @Resource |
| 39 | 43 | private PurchaseOrderRevokeLineService purchaseOrderRevokeLineService; |
| 40 | 44 | @Resource |
| 41 | 45 | private PurchaseOrderInfoService purchaseOrderInfoService; |
| 46 | + @Resource | |
| 47 | + private FlowInstanceWrapperService flowInstanceWrapperService; | |
| 42 | 48 | |
| 43 | 49 | |
| 44 | 50 | @Override |
| ... | ... | @@ -108,6 +114,7 @@ public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOr |
| 108 | 114 | OpLogUtil.setExtra(vo); |
| 109 | 115 | |
| 110 | 116 | //新增订货单撤销表物料行 |
| 117 | + BigDecimal sumRevokeQuantity = BigDecimal.ZERO; | |
| 111 | 118 | if (CollectionUtil.isNotEmpty(vo.getPurchaseOrderRevokeLineList())) { |
| 112 | 119 | List<PurchaseOrderRevokeLine> purchaseOrderRevokeLineList = vo.getPurchaseOrderRevokeLineList(); |
| 113 | 120 | for (PurchaseOrderRevokeLine purchaseOrderRevokeLine : purchaseOrderRevokeLineList) { |
| ... | ... | @@ -129,14 +136,25 @@ public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOr |
| 129 | 136 | vo1.setQuantity(purchaseOrderRevokeLine.getQuantity()); |
| 130 | 137 | vo1.setSalesPrice(purchaseOrderRevokeLine.getSalesPrice()); |
| 131 | 138 | vo1.setDeliveryDate(purchaseOrderRevokeLine.getDeliveryDate()); |
| 139 | + if (purchaseOrderRevokeLine.getRevokeQuantity() != null) { | |
| 140 | + BigDecimal value = new BigDecimal(String.valueOf(purchaseOrderRevokeLine.getRevokeQuantity())); | |
| 141 | + // 累加,注意要重新赋值 | |
| 142 | + sumRevokeQuantity = sumRevokeQuantity.add(value); | |
| 143 | + } | |
| 132 | 144 | vo1.setRevokeQuantity(purchaseOrderRevokeLine.getRevokeQuantity()); |
| 133 | 145 | vo1.setShowOrder(purchaseOrderRevokeLine.getShowOrder()); |
| 134 | 146 | purchaseOrderRevokeLineService.create(vo1); |
| 135 | 147 | } |
| 136 | 148 | } |
| 149 | + // 转换为吨:除以 1000 | |
| 150 | + BigDecimal bigDecimal = sumRevokeQuantity.divide(new BigDecimal("1000"), 6, RoundingMode.HALF_UP); | |
| 151 | + data.setSumRevokeQuantity(bigDecimal); | |
| 137 | 152 | //更新订货单撤销状态为:撤销中 |
| 138 | 153 | purchaseOrderInfoService.updateRevokeStatus(vo.getPurchaseOrderId(), "UNDOING"); |
| 139 | 154 | |
| 155 | + //开启审核 | |
| 156 | + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data); | |
| 157 | + | |
| 140 | 158 | return data.getId(); |
| 141 | 159 | } |
| 142 | 160 | |
| ... | ... | @@ -161,12 +179,23 @@ public class PurchaseOrderRevokeServiceImpl extends BaseMpServiceImpl<PurchaseOr |
| 161 | 179 | getBaseMapper().update(updateWrapper); |
| 162 | 180 | |
| 163 | 181 | //撤销单物料行修改 |
| 182 | + BigDecimal sumRevokeQuantity = BigDecimal.ZERO; | |
| 164 | 183 | List<UpdatePurchaseOrderRevokeLineVo> voList = vo.getUpdatePurchaseOrderRevokeLineVoList(); |
| 165 | 184 | if (CollectionUtil.isNotEmpty(voList)) { |
| 166 | 185 | for (UpdatePurchaseOrderRevokeLineVo vo1 : voList) { |
| 186 | + if (vo1.getRevokeQuantity() != null) { | |
| 187 | + BigDecimal value = new BigDecimal(String.valueOf(vo1.getRevokeQuantity())); | |
| 188 | + // 累加,注意要重新赋值 | |
| 189 | + sumRevokeQuantity = sumRevokeQuantity.add(value); | |
| 190 | + } | |
| 167 | 191 | purchaseOrderRevokeLineService.update(vo1); |
| 168 | 192 | } |
| 169 | 193 | } |
| 194 | + // 转换为吨:除以 1000 | |
| 195 | + BigDecimal bigDecimal = sumRevokeQuantity.divide(new BigDecimal("1000"), 6, RoundingMode.HALF_UP); | |
| 196 | + data.setSumRevokeQuantity(bigDecimal); | |
| 197 | + //开启审核 | |
| 198 | + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data); | |
| 170 | 199 | |
| 171 | 200 | OpLogUtil.setVariable("id", data.getId()); |
| 172 | 201 | OpLogUtil.setExtra(vo); | ... | ... |
| ... | ... | @@ -6,6 +6,8 @@ import com.lframework.xingyun.sc.entity.PurchaseOrderLine; |
| 6 | 6 | import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderLineVo; |
| 7 | 7 | import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo; |
| 8 | 8 | import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderLineVo; |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 9 | 11 | import java.util.List; |
| 10 | 12 | |
| 11 | 13 | /** |
| ... | ... | @@ -47,6 +49,14 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin |
| 47 | 49 | void update(UpdatePurchaseOrderLineVo vo); |
| 48 | 50 | |
| 49 | 51 | /** |
| 52 | + * 修改数量 | |
| 53 | + * | |
| 54 | + * @param id 主建 | |
| 55 | + * @param quantity 数量 | |
| 56 | + */ | |
| 57 | + void updateQuantity(String id, BigDecimal quantity); | |
| 58 | + | |
| 59 | + /** | |
| 50 | 60 | * 根据ID删除 |
| 51 | 61 | * @param id |
| 52 | 62 | * @return | ... | ... |