Showing
14 changed files
with
315 additions
and
42 deletions
| @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; | @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; | 4 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; |
| 5 | import com.lframework.starter.common.constants.StringPool; | 5 | import com.lframework.starter.common.constants.StringPool; |
| 6 | import com.lframework.starter.web.core.bo.BaseBo; | 6 | import com.lframework.starter.web.core.bo.BaseBo; |
| 7 | + | ||
| 8 | +import java.math.BigDecimal; | ||
| 7 | import java.time.LocalDate; | 9 | import java.time.LocalDate; |
| 8 | import java.time.LocalTime; | 10 | import java.time.LocalTime; |
| 9 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
| @@ -40,6 +42,18 @@ public class ShipmentsPlanDetailBo extends BaseBo<ShipmentsPlanDetail> { | @@ -40,6 +42,18 @@ public class ShipmentsPlanDetailBo extends BaseBo<ShipmentsPlanDetail> { | ||
| 40 | private String orderId; | 42 | private String orderId; |
| 41 | 43 | ||
| 42 | /** | 44 | /** |
| 45 | + * 订单编号 | ||
| 46 | + */ | ||
| 47 | + @ApiModelProperty("订单编号") | ||
| 48 | + private String orderNo; | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 客户名称 | ||
| 52 | + */ | ||
| 53 | + @ApiModelProperty("客户名称") | ||
| 54 | + private String customerName; | ||
| 55 | + | ||
| 56 | + /** | ||
| 43 | * 父类ID | 57 | * 父类ID |
| 44 | */ | 58 | */ |
| 45 | @ApiModelProperty("父类ID") | 59 | @ApiModelProperty("父类ID") |
| @@ -72,6 +86,66 @@ public class ShipmentsPlanDetailBo extends BaseBo<ShipmentsPlanDetail> { | @@ -72,6 +86,66 @@ public class ShipmentsPlanDetailBo extends BaseBo<ShipmentsPlanDetail> { | ||
| 72 | private Boolean canShipments; | 86 | private Boolean canShipments; |
| 73 | 87 | ||
| 74 | /** | 88 | /** |
| 89 | + * 厚度 | ||
| 90 | + */ | ||
| 91 | + @ApiModelProperty("厚度") | ||
| 92 | + private BigDecimal thickness; | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 厚度公差正 | ||
| 96 | + */ | ||
| 97 | + @ApiModelProperty("厚度公差正") | ||
| 98 | + private BigDecimal thicknessTolPos; | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * 厚度公差负 | ||
| 102 | + */ | ||
| 103 | + @ApiModelProperty("厚度公差负") | ||
| 104 | + private BigDecimal thicknessTolNeg; | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * 宽度 | ||
| 108 | + */ | ||
| 109 | + @ApiModelProperty("宽度") | ||
| 110 | + private BigDecimal width; | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * 宽度公差正 | ||
| 114 | + */ | ||
| 115 | + @ApiModelProperty("宽度公差正") | ||
| 116 | + private BigDecimal widthTolPos; | ||
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * 宽度公差负 | ||
| 120 | + */ | ||
| 121 | + @ApiModelProperty("宽度公差负") | ||
| 122 | + private BigDecimal widthTolNeg; | ||
| 123 | + | ||
| 124 | + /** | ||
| 125 | + * 长度 | ||
| 126 | + */ | ||
| 127 | + @ApiModelProperty("长度") | ||
| 128 | + private BigDecimal length; | ||
| 129 | + | ||
| 130 | + /** | ||
| 131 | + * 长度公差正 | ||
| 132 | + */ | ||
| 133 | + @ApiModelProperty("长度公差正") | ||
| 134 | + private BigDecimal lengthTolPos; | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * 长度公差负 | ||
| 138 | + */ | ||
| 139 | + @ApiModelProperty("长度公差负") | ||
| 140 | + private BigDecimal lengthTolNeg; | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 计划吨位 | ||
| 144 | + */ | ||
| 145 | + @ApiModelProperty("计划吨位") | ||
| 146 | + private BigDecimal quantity; | ||
| 147 | + | ||
| 148 | + /** | ||
| 75 | * 创建人ID | 149 | * 创建人ID |
| 76 | */ | 150 | */ |
| 77 | @ApiModelProperty("创建人ID") | 151 | @ApiModelProperty("创建人ID") |
| @@ -308,7 +308,7 @@ public class ScSelectorController extends DefaultBaseController { | @@ -308,7 +308,7 @@ public class ScSelectorController extends DefaultBaseController { | ||
| 308 | orderIds.add(orderInfo.getId()); | 308 | orderIds.add(orderInfo.getId()); |
| 309 | } | 309 | } |
| 310 | // 获取物料行数据 | 310 | // 获取物料行数据 |
| 311 | - List<PurchaseOrderLine> orderLineList = orderLineService.listByOrderIds(orderIds); | 311 | + List<PurchaseOrderLine> orderLineList = orderLineService.listByOrderIds(orderIds, false); |
| 312 | if (CollectionUtils.isEmpty(orderLineList)) { | 312 | if (CollectionUtils.isEmpty(orderLineList)) { |
| 313 | return InvokeResultBuilder.success(result); | 313 | return InvokeResultBuilder.success(result); |
| 314 | } | 314 | } |
| 1 | package com.lframework.xingyun.sc.controller.shipments; | 1 | package com.lframework.xingyun.sc.controller.shipments; |
| 2 | 2 | ||
| 3 | import com.lframework.xingyun.sc.bo.shipments.plan.ShipmentsPlanDetailBo; | 3 | import com.lframework.xingyun.sc.bo.shipments.plan.ShipmentsPlanDetailBo; |
| 4 | -import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService; | ||
| 5 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; | 4 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; |
| 6 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; | 5 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; |
| 7 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; | 6 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; |
| 7 | +import com.lframework.xingyun.sc.vo.shipments.plan.ShipmentsPlanDetailSplitVo; | ||
| 8 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; | 8 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; |
| 9 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; | 9 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; |
| 10 | import com.lframework.starter.web.core.utils.PageResultUtil; | 10 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| 11 | import com.lframework.starter.web.core.components.resp.PageResult; | 11 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 12 | import com.lframework.starter.web.core.components.resp.InvokeResult; | 12 | import com.lframework.starter.web.core.components.resp.InvokeResult; |
| 13 | + | ||
| 14 | +import javax.annotation.Resource; | ||
| 13 | import javax.validation.constraints.NotBlank; | 15 | import javax.validation.constraints.NotBlank; |
| 14 | import io.swagger.annotations.ApiImplicitParam; | 16 | import io.swagger.annotations.ApiImplicitParam; |
| 15 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | 17 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
| @@ -18,7 +20,6 @@ import io.swagger.annotations.ApiOperation; | @@ -18,7 +20,6 @@ import io.swagger.annotations.ApiOperation; | ||
| 18 | import com.lframework.starter.common.utils.CollectionUtil; | 20 | import com.lframework.starter.common.utils.CollectionUtil; |
| 19 | import io.swagger.annotations.Api; | 21 | import io.swagger.annotations.Api; |
| 20 | import com.lframework.starter.web.core.controller.DefaultBaseController; | 22 | import com.lframework.starter.web.core.controller.DefaultBaseController; |
| 21 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 22 | import com.lframework.starter.web.core.annotations.security.HasPermission; | 23 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 23 | import org.springframework.validation.annotation.Validated; | 24 | import org.springframework.validation.annotation.Validated; |
| 24 | import org.springframework.web.bind.annotation.*; | 25 | import org.springframework.web.bind.annotation.*; |
| @@ -37,10 +38,8 @@ import java.util.stream.Collectors; | @@ -37,10 +38,8 @@ import java.util.stream.Collectors; | ||
| 37 | @RequestMapping("/shipments/plan/detail") | 38 | @RequestMapping("/shipments/plan/detail") |
| 38 | public class ShipmentsPlanDetailController extends DefaultBaseController { | 39 | public class ShipmentsPlanDetailController extends DefaultBaseController { |
| 39 | 40 | ||
| 40 | - @Autowired | 41 | + @Resource |
| 41 | private ShipmentsPlanDetailService shipmentsPlanDetailService; | 42 | private ShipmentsPlanDetailService shipmentsPlanDetailService; |
| 42 | - @Autowired | ||
| 43 | - private ShipmentsPlanService shipmentsPlanService; | ||
| 44 | 43 | ||
| 45 | /** | 44 | /** |
| 46 | * 查询列表 | 45 | * 查询列表 |
| @@ -110,4 +109,15 @@ public class ShipmentsPlanDetailController extends DefaultBaseController { | @@ -110,4 +109,15 @@ public class ShipmentsPlanDetailController extends DefaultBaseController { | ||
| 110 | } | 109 | } |
| 111 | return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | 110 | return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); |
| 112 | } | 111 | } |
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * 拆分 | ||
| 115 | + */ | ||
| 116 | + @ApiOperation("拆分") | ||
| 117 | + @HasPermission({"shipments:plan:add"}) | ||
| 118 | + @PostMapping("/split") | ||
| 119 | + public InvokeResult<Void> split(@Valid @RequestBody ShipmentsPlanDetailSplitVo vo) { | ||
| 120 | + shipmentsPlanDetailService.planDetailSplit(vo); | ||
| 121 | + return InvokeResultBuilder.success(); | ||
| 122 | + } | ||
| 113 | } | 123 | } |
| @@ -30,7 +30,7 @@ public class PurchaseOrderLine extends BaseEntity implements BaseDto { | @@ -30,7 +30,7 @@ public class PurchaseOrderLine extends BaseEntity implements BaseDto { | ||
| 30 | private String id; | 30 | private String id; |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | - * 订货单主表ID | 33 | + * 订货单主表ID/订货单变更记录ID |
| 34 | */ | 34 | */ |
| 35 | private String purchaseOrderId; | 35 | private String purchaseOrderId; |
| 36 | 36 | ||
| @@ -131,6 +131,22 @@ public class PurchaseOrderLine extends BaseEntity implements BaseDto { | @@ -131,6 +131,22 @@ public class PurchaseOrderLine extends BaseEntity implements BaseDto { | ||
| 131 | private String assessmentExceedsAgreement; | 131 | private String assessmentExceedsAgreement; |
| 132 | 132 | ||
| 133 | /** | 133 | /** |
| 134 | + * 父类ID | ||
| 135 | + * 拆分时使用 | ||
| 136 | + */ | ||
| 137 | + private String parentId; | ||
| 138 | + | ||
| 139 | + /** | ||
| 140 | + * 是否已发货 | ||
| 141 | + */ | ||
| 142 | + private Boolean shipment; | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * 是否已删除 | ||
| 146 | + */ | ||
| 147 | + private Boolean delFlag; | ||
| 148 | + | ||
| 149 | + /** | ||
| 134 | * 创建人ID | 150 | * 创建人ID |
| 135 | */ | 151 | */ |
| 136 | @TableField(fill = FieldFill.INSERT) | 152 | @TableField(fill = FieldFill.INSERT) |
| @@ -93,7 +93,7 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR | @@ -93,7 +93,7 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR | ||
| 93 | List<PurchaseOrderLine> beforeChangeList = JsonUtil.parseList(obj.toString(), PurchaseOrderLine.class); | 93 | List<PurchaseOrderLine> beforeChangeList = JsonUtil.parseList(obj.toString(), PurchaseOrderLine.class); |
| 94 | changeRecord.setBeforeChangeSpecList(beforeChangeList); | 94 | changeRecord.setBeforeChangeSpecList(beforeChangeList); |
| 95 | // 变更后 | 95 | // 变更后 |
| 96 | - List<PurchaseOrderLine> afterChangeList = purchaseOrderLineService.listByOrderIds(Collections.singletonList(id)); | 96 | + List<PurchaseOrderLine> afterChangeList = purchaseOrderLineService.listByOrderIds(Collections.singletonList(id), true); |
| 97 | changeRecord.setAfterChangeSpecList(afterChangeList); | 97 | changeRecord.setAfterChangeSpecList(afterChangeList); |
| 98 | 98 | ||
| 99 | return changeRecord; | 99 | return changeRecord; |
| @@ -189,7 +189,7 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR | @@ -189,7 +189,7 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR | ||
| 189 | purchaseOrderLineService.create(orderLineVo); | 189 | purchaseOrderLineService.create(orderLineVo); |
| 190 | } | 190 | } |
| 191 | // 缓存订货单物料行数据 | 191 | // 缓存订货单物料行数据 |
| 192 | - List<PurchaseOrderLine> orderLineList = purchaseOrderLineService.listByOrderIds(Collections.singletonList(data.getOrderId())); | 192 | + List<PurchaseOrderLine> orderLineList = purchaseOrderLineService.listByOrderIds(Collections.singletonList(data.getOrderId()), true); |
| 193 | redisHandler.set(vo.getOrderId() + "_order_line_info", JsonUtil.toJsonString(orderLineList)); | 193 | redisHandler.set(vo.getOrderId() + "_order_line_info", JsonUtil.toJsonString(orderLineList)); |
| 194 | // 更新订货单变更状态 | 194 | // 更新订货单变更状态 |
| 195 | purchaseOrderInfoService.updateSpecChangeStatus(vo.getOrderId(), OrderSpecChangeStatus.IN_PROGRESS.getCode()); | 195 | purchaseOrderInfoService.updateSpecChangeStatus(vo.getOrderId(), OrderSpecChangeStatus.IN_PROGRESS.getCode()); |
| @@ -198,13 +198,17 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde | @@ -198,13 +198,17 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde | ||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | @Override | 200 | @Override |
| 201 | - public List<PurchaseOrderLine> listByOrderIds(List<String> orderIds) { | 201 | + public List<PurchaseOrderLine> listByOrderIds(List<String> orderIds, boolean includeShipment) { |
| 202 | if (CollectionUtils.isEmpty(orderIds)) { | 202 | if (CollectionUtils.isEmpty(orderIds)) { |
| 203 | return Collections.emptyList(); | 203 | return Collections.emptyList(); |
| 204 | } | 204 | } |
| 205 | LambdaQueryWrapper<PurchaseOrderLine> queryWrapper = Wrappers.lambdaQuery(PurchaseOrderLine.class); | 205 | LambdaQueryWrapper<PurchaseOrderLine> queryWrapper = Wrappers.lambdaQuery(PurchaseOrderLine.class); |
| 206 | - queryWrapper.in(PurchaseOrderLine::getPurchaseOrderId, orderIds) | ||
| 207 | - .orderByAsc(PurchaseOrderLine::getShowOrder); | 206 | + queryWrapper.eq(PurchaseOrderLine::getDelFlag, Boolean.FALSE) |
| 207 | + .in(PurchaseOrderLine::getPurchaseOrderId, orderIds); | ||
| 208 | + if (!includeShipment) { | ||
| 209 | + queryWrapper.eq(PurchaseOrderLine::getShipment, Boolean.FALSE); | ||
| 210 | + } | ||
| 211 | + queryWrapper.orderByAsc(PurchaseOrderLine::getShowOrder); | ||
| 208 | 212 | ||
| 209 | return getBaseMapper().selectList(queryWrapper); | 213 | return getBaseMapper().selectList(queryWrapper); |
| 210 | } | 214 | } |
| @@ -266,6 +270,18 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde | @@ -266,6 +270,18 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde | ||
| 266 | } | 270 | } |
| 267 | 271 | ||
| 268 | @Override | 272 | @Override |
| 273 | + public void logicDelById(String id) { | ||
| 274 | + if (StringUtils.isEmpty(id)) { | ||
| 275 | + return; | ||
| 276 | + } | ||
| 277 | + LambdaUpdateWrapper<PurchaseOrderLine> updateWrapper = Wrappers.lambdaUpdate(PurchaseOrderLine.class); | ||
| 278 | + updateWrapper.set(PurchaseOrderLine::getDelFlag, Boolean.TRUE) | ||
| 279 | + .eq(PurchaseOrderLine::getId, id); | ||
| 280 | + | ||
| 281 | + getBaseMapper().update(updateWrapper); | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + @Override | ||
| 269 | public void cleanCacheByKey(Serializable key) { | 285 | public void cleanCacheByKey(Serializable key) { |
| 270 | 286 | ||
| 271 | } | 287 | } |
| @@ -23,14 +23,17 @@ import com.lframework.xingyun.sc.mappers.ShipmentsPlanDetailMapper; | @@ -23,14 +23,17 @@ import com.lframework.xingyun.sc.mappers.ShipmentsPlanDetailMapper; | ||
| 23 | import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; | 23 | import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; |
| 24 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; | 24 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; |
| 25 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService; | 25 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService; |
| 26 | +import com.lframework.xingyun.sc.utils.CommonUtil; | ||
| 26 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; | 27 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; |
| 27 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; | 28 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; |
| 29 | +import com.lframework.xingyun.sc.vo.shipments.plan.ShipmentsPlanDetailSplitVo; | ||
| 28 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; | 30 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; |
| 29 | import org.apache.commons.collections4.CollectionUtils; | 31 | import org.apache.commons.collections4.CollectionUtils; |
| 30 | import org.springframework.stereotype.Service; | 32 | import org.springframework.stereotype.Service; |
| 31 | import org.springframework.transaction.annotation.Transactional; | 33 | import org.springframework.transaction.annotation.Transactional; |
| 32 | 34 | ||
| 33 | import javax.annotation.Resource; | 35 | import javax.annotation.Resource; |
| 36 | +import java.math.BigDecimal; | ||
| 34 | import java.time.LocalDate; | 37 | import java.time.LocalDate; |
| 35 | import java.util.ArrayList; | 38 | import java.util.ArrayList; |
| 36 | import java.util.List; | 39 | import java.util.List; |
| @@ -148,7 +151,7 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP | @@ -148,7 +151,7 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP | ||
| 148 | .select(ShipmentsPlanDetail::getOrderSpecId); | 151 | .select(ShipmentsPlanDetail::getOrderSpecId); |
| 149 | List<ShipmentsPlanDetail> shipmentsPlanDetails = getBaseMapper().selectList(queryWrapper); | 152 | List<ShipmentsPlanDetail> shipmentsPlanDetails = getBaseMapper().selectList(queryWrapper); |
| 150 | if (CollectionUtils.isNotEmpty(shipmentsPlanDetails)) { | 153 | if (CollectionUtils.isNotEmpty(shipmentsPlanDetails)) { |
| 151 | - List<String> orderSpecIds = shipmentsPlanDetails.stream().map(ShipmentsPlanDetail::getId).collect(Collectors.toList()); | 154 | + List<String> orderSpecIds = shipmentsPlanDetails.stream().map(ShipmentsPlanDetail::getOrderSpecId).collect(Collectors.toList()); |
| 152 | vo.setOrderSpecIds(orderSpecIds); | 155 | vo.setOrderSpecIds(orderSpecIds); |
| 153 | } | 156 | } |
| 154 | // 开启分页 | 157 | // 开启分页 |
| @@ -157,4 +160,75 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP | @@ -157,4 +160,75 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP | ||
| 157 | 160 | ||
| 158 | return PageResultUtil.convert(new PageInfo<>(dataList)); | 161 | return PageResultUtil.convert(new PageInfo<>(dataList)); |
| 159 | } | 162 | } |
| 163 | + | ||
| 164 | + /** | ||
| 165 | + * 计划明细拆分 | ||
| 166 | + * | ||
| 167 | + * @param vo 条件 | ||
| 168 | + */ | ||
| 169 | + @Override | ||
| 170 | + public void planDetailSplit(ShipmentsPlanDetailSplitVo vo) { | ||
| 171 | + String id = vo.getId(); | ||
| 172 | + ShipmentsPlanDetail detail = findById(id); | ||
| 173 | + if (detail == null) { | ||
| 174 | + throw new DefaultClientException("计划明细不存在!"); | ||
| 175 | + } | ||
| 176 | + // 获取订货单规格数据 | ||
| 177 | + PurchaseOrderLine orderLine = purchaseOrderLineService.findById(detail.getOrderSpecId()); | ||
| 178 | + // 判断拆分后总数量是否变化 | ||
| 179 | + List<BigDecimal> splitQuantityList = vo.getSplitQuantityList(); | ||
| 180 | + boolean match = CommonUtil.isQuantityMatchWithScale(splitQuantityList, orderLine.getQuantity(), 4); | ||
| 181 | + if (!match) { | ||
| 182 | + throw new DefaultClientException("拆分数量总和必须等于原先数量!"); | ||
| 183 | + } | ||
| 184 | + // 封装数据 | ||
| 185 | + String userId = SecurityUtil.getCurrentUser().getId(); | ||
| 186 | + List<ShipmentsPlanDetail> detailList = new ArrayList<>(); | ||
| 187 | + List<PurchaseOrderLine> orderLineList = new ArrayList<>(); | ||
| 188 | + for (BigDecimal quantity : splitQuantityList) { | ||
| 189 | + ShipmentsPlanDetail data = getShipmentsPlanDetail(quantity, detail, userId); | ||
| 190 | + detailList.add(data); | ||
| 191 | + // 封装订货单规格数据 | ||
| 192 | + PurchaseOrderLine copyLineInfo = CommonUtil.deepCopy(orderLine); | ||
| 193 | + copyLineInfo.setId(data.getOrderSpecId()); | ||
| 194 | + copyLineInfo.setParentId(orderLine.getId()); | ||
| 195 | + copyLineInfo.setQuantity(quantity); | ||
| 196 | + | ||
| 197 | + orderLineList.add(copyLineInfo); | ||
| 198 | + } | ||
| 199 | + getBaseMapper().batchAdd(detailList); | ||
| 200 | + // 删除计划明细数据(逻辑删除) | ||
| 201 | + LambdaUpdateWrapper<ShipmentsPlanDetail> updateWrapper = Wrappers.lambdaUpdate(ShipmentsPlanDetail.class); | ||
| 202 | + updateWrapper.set(ShipmentsPlanDetail::getDelFlag, Boolean.TRUE) | ||
| 203 | + .eq(ShipmentsPlanDetail::getId, id); | ||
| 204 | + getBaseMapper().update(updateWrapper); | ||
| 205 | + // 同步订货单规格数据 | ||
| 206 | + purchaseOrderLineService.logicDelById(orderLine.getId()); | ||
| 207 | + purchaseOrderLineService.batchAdd(orderLineList); | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + | ||
| 211 | + /** | ||
| 212 | + * 封装发货计划明细数据 | ||
| 213 | + * | ||
| 214 | + * @param quantity 数量 | ||
| 215 | + * @param detail 原数据 | ||
| 216 | + * @param userId 人员ID | ||
| 217 | + * @return ShipmentsPlanDetail | ||
| 218 | + */ | ||
| 219 | + private static ShipmentsPlanDetail getShipmentsPlanDetail(BigDecimal quantity, ShipmentsPlanDetail detail, String userId) { | ||
| 220 | + ShipmentsPlanDetail data = new ShipmentsPlanDetail(); | ||
| 221 | + data.setId(IdUtil.getId()); | ||
| 222 | + data.setPlanId(detail.getPlanId()); | ||
| 223 | + data.setOrderId(detail.getOrderId()); | ||
| 224 | + data.setOrderSpecId(IdUtil.getId()); | ||
| 225 | + data.setParentId(detail.getId()); | ||
| 226 | + data.setShipmentsDate(detail.getShipmentsDate()); | ||
| 227 | + data.setQuantity(quantity); | ||
| 228 | + data.setPreShipments(Boolean.FALSE); | ||
| 229 | + data.setCreateById(userId); | ||
| 230 | + data.setUpdateById(userId); | ||
| 231 | + data.setDelFlag(Boolean.FALSE); | ||
| 232 | + return data; | ||
| 233 | + } | ||
| 160 | } | 234 | } |
| @@ -66,10 +66,11 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin | @@ -66,10 +66,11 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin | ||
| 66 | /** | 66 | /** |
| 67 | * 根据订货单ID查询 | 67 | * 根据订货单ID查询 |
| 68 | * | 68 | * |
| 69 | - * @param orderIds 订货单ID集合 | ||
| 70 | - * @return List<PurchaseOrderLine> | 69 | + * @param orderIds 订货单ID集合 |
| 70 | + * @param includeShipment 是否包含已发货数据 | ||
| 71 | + * @return List<PurchaseOrderLine> | ||
| 71 | */ | 72 | */ |
| 72 | - List<PurchaseOrderLine> listByOrderIds(List<String> orderIds); | 73 | + List<PurchaseOrderLine> listByOrderIds(List<String> orderIds, boolean includeShipment); |
| 73 | 74 | ||
| 74 | /** | 75 | /** |
| 75 | * 批量新增 | 76 | * 批量新增 |
| @@ -98,4 +99,11 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin | @@ -98,4 +99,11 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin | ||
| 98 | * @param orderId 订货单ID | 99 | * @param orderId 订货单ID |
| 99 | */ | 100 | */ |
| 100 | void deleteByOrderId(String orderId); | 101 | void deleteByOrderId(String orderId); |
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * 根据ID逻辑删除 | ||
| 105 | + * | ||
| 106 | + * @param id 主键ID | ||
| 107 | + */ | ||
| 108 | + void logicDelById(String id); | ||
| 101 | } | 109 | } |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/service/shipments/ShipmentsPlanDetailService.java
| @@ -2,32 +2,11 @@ package com.lframework.xingyun.sc.service.shipments; | @@ -2,32 +2,11 @@ package com.lframework.xingyun.sc.service.shipments; | ||
| 2 | 2 | ||
| 3 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; | 3 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; |
| 4 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; | 4 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; |
| 5 | +import com.lframework.xingyun.sc.vo.shipments.plan.ShipmentsPlanDetailSplitVo; | ||
| 5 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; | 6 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; |
| 6 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; | 7 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; |
| 7 | -import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | ||
| 8 | -import com.lframework.starter.web.core.utils.PageResultUtil; | ||
| 9 | import com.lframework.starter.web.core.service.BaseMpService; | 8 | import com.lframework.starter.web.core.service.BaseMpService; |
| 10 | import com.lframework.starter.web.core.components.resp.PageResult; | 9 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 11 | -import javax.validation.constraints.NotBlank; | ||
| 12 | -import com.lframework.starter.web.core.vo.PageVo; | ||
| 13 | -import com.lframework.starter.web.core.utils.OpLogUtil; | ||
| 14 | -import com.lframework.starter.common.utils.StringUtil; | ||
| 15 | -import com.lframework.starter.web.core.vo.BaseVo; | ||
| 16 | -import javax.validation.constraints.NotNull; | ||
| 17 | -import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 18 | -import com.lframework.starter.common.exceptions.impl.DefaultClientException; | ||
| 19 | -import java.time.LocalDate; | ||
| 20 | -import com.lframework.starter.web.core.utils.EnumUtil; | ||
| 21 | -import com.lframework.starter.web.core.utils.IdUtil; | ||
| 22 | -import java.time.LocalTime; | ||
| 23 | -import com.lframework.starter.common.utils.ObjectUtil; | ||
| 24 | -import com.lframework.starter.web.core.annotations.oplog.OpLog; | ||
| 25 | -import com.lframework.starter.web.core.utils.PageHelperUtil; | ||
| 26 | -import com.lframework.starter.common.utils.Assert; | ||
| 27 | -import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | ||
| 28 | -import io.swagger.annotations.ApiModelProperty; | ||
| 29 | -import org.hibernate.validator.constraints.Length; | ||
| 30 | -import java.util.Collection; | ||
| 31 | import java.util.List; | 10 | import java.util.List; |
| 32 | 11 | ||
| 33 | /** | 12 | /** |
| @@ -82,4 +61,11 @@ public interface ShipmentsPlanDetailService extends BaseMpService<ShipmentsPlanD | @@ -82,4 +61,11 @@ public interface ShipmentsPlanDetailService extends BaseMpService<ShipmentsPlanD | ||
| 82 | * @return PageResult<ShipmentsPlanDetail> | 61 | * @return PageResult<ShipmentsPlanDetail> |
| 83 | */ | 62 | */ |
| 84 | PageResult<ShipmentsPlanDetail> queryCanShipmentsData(Integer pageIndex, Integer pageSize, QueryShipmentsPlanDetailVo vo); | 63 | PageResult<ShipmentsPlanDetail> queryCanShipmentsData(Integer pageIndex, Integer pageSize, QueryShipmentsPlanDetailVo vo); |
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * 计划明细拆分 | ||
| 67 | + * | ||
| 68 | + * @param vo 条件 | ||
| 69 | + */ | ||
| 70 | + void planDetailSplit(ShipmentsPlanDetailSplitVo vo); | ||
| 85 | } | 71 | } |
| 1 | +package com.lframework.xingyun.sc.utils; | ||
| 2 | + | ||
| 3 | +import lombok.extern.slf4j.Slf4j; | ||
| 4 | + | ||
| 5 | +import java.io.*; | ||
| 6 | +import java.math.BigDecimal; | ||
| 7 | +import java.math.RoundingMode; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Slf4j | ||
| 11 | +public class CommonUtil { | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 深度拷贝 | ||
| 17 | + * | ||
| 18 | + * @param object 被拷贝对象 | ||
| 19 | + * @return T | ||
| 20 | + */ | ||
| 21 | + public static <T> T deepCopy(T object) { | ||
| 22 | + try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | ||
| 23 | + ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream)) { | ||
| 24 | + objectOutputStream.writeObject(object); | ||
| 25 | + try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); | ||
| 26 | + ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream)) { | ||
| 27 | + return (T) objectInputStream.readObject(); | ||
| 28 | + } | ||
| 29 | + } catch (IOException | ClassNotFoundException e) { | ||
| 30 | + throw new RuntimeException(e); | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 比较数量是否相等 | ||
| 37 | + * | ||
| 38 | + * @param splitQuantityList 数值集合 | ||
| 39 | + * @param quantity 数值 | ||
| 40 | + * @param scale 小数位 | ||
| 41 | + * @return boolean | ||
| 42 | + */ | ||
| 43 | + public static boolean isQuantityMatchWithScale(List<BigDecimal> splitQuantityList, BigDecimal quantity, int scale) { | ||
| 44 | + // 计算总和 | ||
| 45 | + BigDecimal sum = splitQuantityList.stream() | ||
| 46 | + .reduce(BigDecimal.ZERO, BigDecimal::add) | ||
| 47 | + .setScale(scale, RoundingMode.HALF_UP); | ||
| 48 | + | ||
| 49 | + BigDecimal target = quantity.setScale(scale, RoundingMode.HALF_UP); | ||
| 50 | + return sum.compareTo(target) == 0; | ||
| 51 | + } | ||
| 52 | +} |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/shipments/plan/ShipmentsPlanDetailSplitVo.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.vo.shipments.plan; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 4 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 5 | +import com.lframework.starter.web.core.vo.PageVo; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import javax.validation.constraints.NotBlank; | ||
| 10 | +import javax.validation.constraints.NotEmpty; | ||
| 11 | +import java.io.Serializable; | ||
| 12 | +import java.math.BigDecimal; | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 15 | +@Data | ||
| 16 | +public class ShipmentsPlanDetailSplitVo extends PageVo implements BaseVo, Serializable { | ||
| 17 | + | ||
| 18 | + private static final long serialVersionUID = 1L; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 发货计划明细ID | ||
| 22 | + */ | ||
| 23 | + @ApiModelProperty("发货计划明细ID") | ||
| 24 | + @NotBlank(message = "发货计划明细ID不能为空!") | ||
| 25 | + private String id; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 拆分数量集合 | ||
| 29 | + */ | ||
| 30 | + @ApiModelProperty("拆分数量集合") | ||
| 31 | + @NotEmpty(message = "拆分数量不能为空") | ||
| 32 | + @TypeMismatch(message = "拆分数量格式有误!") | ||
| 33 | + private List<BigDecimal> splitQuantityList; | ||
| 34 | +} |
| @@ -180,12 +180,13 @@ | @@ -180,12 +180,13 @@ | ||
| 180 | tb.revoke_status='PARTIAL') | 180 | tb.revoke_status='PARTIAL') |
| 181 | AND (tb.status='ISSUED' OR tb.status='WAIT' OR tb.status='TRANSIT') | 181 | AND (tb.status='ISSUED' OR tb.status='WAIT' OR tb.status='TRANSIT') |
| 182 | AND tb.examine_status = 'PASS' | 182 | AND tb.examine_status = 'PASS' |
| 183 | - AND tb.spec_change_status != 'IN_PROGRESS' | 183 | + AND (tb.spec_change_status != 'IN_PROGRESS' OR tb.spec_change_status IS NULL) |
| 184 | </when> | 184 | </when> |
| 185 | <when test="vo.queryType == 'CHANGE'"> | 185 | <when test="vo.queryType == 'CHANGE'"> |
| 186 | AND tb.examine_status = 'PASS' | 186 | AND tb.examine_status = 'PASS' |
| 187 | AND tb.status != 'SHIPPED' | 187 | AND tb.status != 'SHIPPED' |
| 188 | AND (tb.revoke_status != 'UNDOING' OR tb.revoke_status IS NULL) | 188 | AND (tb.revoke_status != 'UNDOING' OR tb.revoke_status IS NULL) |
| 189 | + AND (tb.spec_change_status != 'IN_PROGRESS' OR tb.spec_change_status IS NULL) | ||
| 189 | </when> | 190 | </when> |
| 190 | <otherwise> | 191 | <otherwise> |
| 191 | AND 1 = 0 <!-- 确保查询不到任何数据 --> | 192 | AND 1 = 0 <!-- 确保查询不到任何数据 --> |
| @@ -65,6 +65,7 @@ | @@ -65,6 +65,7 @@ | ||
| 65 | <select id="query" resultMap="PurchaseOrderLine"> | 65 | <select id="query" resultMap="PurchaseOrderLine"> |
| 66 | <include refid="PurchaseOrderLine_sql"/> | 66 | <include refid="PurchaseOrderLine_sql"/> |
| 67 | <where> | 67 | <where> |
| 68 | + and tb.del_flag = false | ||
| 68 | <if test="vo.purchaseOrderId != null and vo.purchaseOrderId != ''"> | 69 | <if test="vo.purchaseOrderId != null and vo.purchaseOrderId != ''"> |
| 69 | AND tb.purchase_order_id = #{vo.purchaseOrderId} | 70 | AND tb.purchase_order_id = #{vo.purchaseOrderId} |
| 70 | </if> | 71 | </if> |
| @@ -89,7 +90,7 @@ | @@ -89,7 +90,7 @@ | ||
| 89 | length, length_tol_pos, length_tol_neg, | 90 | length, length_tol_pos, length_tol_neg, |
| 90 | status, quantity, sales_price, delivery_date, show_order, | 91 | status, quantity, sales_price, delivery_date, show_order, |
| 91 | assessment_exceeds_agreement, create_by_id, create_by, update_by_id, update_by, | 92 | assessment_exceeds_agreement, create_by_id, create_by, update_by_id, update_by, |
| 92 | - create_time, update_time | 93 | + create_time, update_time, parent_id |
| 93 | ) VALUES | 94 | ) VALUES |
| 94 | <foreach collection="specList" item="item" separator=","> | 95 | <foreach collection="specList" item="item" separator=","> |
| 95 | ( | 96 | ( |
| @@ -99,7 +100,7 @@ | @@ -99,7 +100,7 @@ | ||
| 99 | #{item.length}, #{item.lengthTolPos}, #{item.lengthTolNeg}, | 100 | #{item.length}, #{item.lengthTolPos}, #{item.lengthTolNeg}, |
| 100 | #{item.status}, #{item.quantity}, #{item.salesPrice}, #{item.deliveryDate}, #{item.showOrder}, | 101 | #{item.status}, #{item.quantity}, #{item.salesPrice}, #{item.deliveryDate}, #{item.showOrder}, |
| 101 | #{item.assessmentExceedsAgreement}, #{item.createById}, #{item.createBy}, #{item.updateById}, #{item.updateBy}, | 102 | #{item.assessmentExceedsAgreement}, #{item.createById}, #{item.createBy}, #{item.updateById}, #{item.updateBy}, |
| 102 | - #{item.createTime}, #{item.updateTime} | 103 | + #{item.createTime}, #{item.updateTime}, #{item.parentId} |
| 103 | ) | 104 | ) |
| 104 | </foreach> | 105 | </foreach> |
| 105 | </insert> | 106 | </insert> |
| @@ -61,12 +61,13 @@ | @@ -61,12 +61,13 @@ | ||
| 61 | INNER JOIN shipments_plan p ON tb.plan_id = p.id | 61 | INNER JOIN shipments_plan p ON tb.plan_id = p.id |
| 62 | LEFT JOIN purchase_order_info o ON tb.order_id = o.id | 62 | LEFT JOIN purchase_order_info o ON tb.order_id = o.id |
| 63 | LEFT JOIN base_data_customer c ON o.ordering_unit = c.id | 63 | LEFT JOIN base_data_customer c ON o.ordering_unit = c.id |
| 64 | - LEFT JOIN tbl_purchase_order_line ol ON tb.order_id = ol.purchase_order_id | 64 | + LEFT JOIN tbl_purchase_order_line ol ON tb.order_spec_id = ol.id |
| 65 | </sql> | 65 | </sql> |
| 66 | 66 | ||
| 67 | <select id="query" resultMap="ShipmentsPlanDetail"> | 67 | <select id="query" resultMap="ShipmentsPlanDetail"> |
| 68 | <include refid="ShipmentsPlanDetail_sql"/> | 68 | <include refid="ShipmentsPlanDetail_sql"/> |
| 69 | <where> | 69 | <where> |
| 70 | + and tb.del_flag = false | ||
| 70 | <if test="vo.planId != null and vo.planId != ''"> | 71 | <if test="vo.planId != null and vo.planId != ''"> |
| 71 | AND tb.plan_id = #{vo.planId} | 72 | AND tb.plan_id = #{vo.planId} |
| 72 | </if> | 73 | </if> |