Showing
14 changed files
with
315 additions
and
42 deletions
| ... | ... | @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; |
| 4 | 4 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; |
| 5 | 5 | import com.lframework.starter.common.constants.StringPool; |
| 6 | 6 | import com.lframework.starter.web.core.bo.BaseBo; |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 7 | 9 | import java.time.LocalDate; |
| 8 | 10 | import java.time.LocalTime; |
| 9 | 11 | import java.time.LocalDateTime; |
| ... | ... | @@ -40,6 +42,18 @@ public class ShipmentsPlanDetailBo extends BaseBo<ShipmentsPlanDetail> { |
| 40 | 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 | 57 | * 父类ID |
| 44 | 58 | */ |
| 45 | 59 | @ApiModelProperty("父类ID") |
| ... | ... | @@ -72,6 +86,66 @@ public class ShipmentsPlanDetailBo extends BaseBo<ShipmentsPlanDetail> { |
| 72 | 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 | 149 | * 创建人ID |
| 76 | 150 | */ |
| 77 | 151 | @ApiModelProperty("创建人ID") | ... | ... |
| ... | ... | @@ -308,7 +308,7 @@ public class ScSelectorController extends DefaultBaseController { |
| 308 | 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 | 312 | if (CollectionUtils.isEmpty(orderLineList)) { |
| 313 | 313 | return InvokeResultBuilder.success(result); |
| 314 | 314 | } | ... | ... |
| 1 | 1 | package com.lframework.xingyun.sc.controller.shipments; |
| 2 | 2 | |
| 3 | 3 | import com.lframework.xingyun.sc.bo.shipments.plan.ShipmentsPlanDetailBo; |
| 4 | -import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService; | |
| 5 | 4 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; |
| 6 | 5 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; |
| 7 | 6 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; |
| 7 | +import com.lframework.xingyun.sc.vo.shipments.plan.ShipmentsPlanDetailSplitVo; | |
| 8 | 8 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; |
| 9 | 9 | import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; |
| 10 | 10 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| 11 | 11 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 12 | 12 | import com.lframework.starter.web.core.components.resp.InvokeResult; |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 13 | 15 | import javax.validation.constraints.NotBlank; |
| 14 | 16 | import io.swagger.annotations.ApiImplicitParam; |
| 15 | 17 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
| ... | ... | @@ -18,7 +20,6 @@ import io.swagger.annotations.ApiOperation; |
| 18 | 20 | import com.lframework.starter.common.utils.CollectionUtil; |
| 19 | 21 | import io.swagger.annotations.Api; |
| 20 | 22 | import com.lframework.starter.web.core.controller.DefaultBaseController; |
| 21 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 22 | 23 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 23 | 24 | import org.springframework.validation.annotation.Validated; |
| 24 | 25 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -37,10 +38,8 @@ import java.util.stream.Collectors; |
| 37 | 38 | @RequestMapping("/shipments/plan/detail") |
| 38 | 39 | public class ShipmentsPlanDetailController extends DefaultBaseController { |
| 39 | 40 | |
| 40 | - @Autowired | |
| 41 | + @Resource | |
| 41 | 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 | 109 | } |
| 111 | 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 | 30 | private String id; |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * 订货单主表ID | |
| 33 | + * 订货单主表ID/订货单变更记录ID | |
| 34 | 34 | */ |
| 35 | 35 | private String purchaseOrderId; |
| 36 | 36 | |
| ... | ... | @@ -131,6 +131,22 @@ public class PurchaseOrderLine extends BaseEntity implements BaseDto { |
| 131 | 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 | 150 | * 创建人ID |
| 135 | 151 | */ |
| 136 | 152 | @TableField(fill = FieldFill.INSERT) | ... | ... |
| ... | ... | @@ -93,7 +93,7 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
| 93 | 93 | List<PurchaseOrderLine> beforeChangeList = JsonUtil.parseList(obj.toString(), PurchaseOrderLine.class); |
| 94 | 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 | 97 | changeRecord.setAfterChangeSpecList(afterChangeList); |
| 98 | 98 | |
| 99 | 99 | return changeRecord; |
| ... | ... | @@ -189,7 +189,7 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
| 189 | 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 | 193 | redisHandler.set(vo.getOrderId() + "_order_line_info", JsonUtil.toJsonString(orderLineList)); |
| 194 | 194 | // 更新订货单变更状态 |
| 195 | 195 | purchaseOrderInfoService.updateSpecChangeStatus(vo.getOrderId(), OrderSpecChangeStatus.IN_PROGRESS.getCode()); | ... | ... |
| ... | ... | @@ -198,13 +198,17 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | @Override |
| 201 | - public List<PurchaseOrderLine> listByOrderIds(List<String> orderIds) { | |
| 201 | + public List<PurchaseOrderLine> listByOrderIds(List<String> orderIds, boolean includeShipment) { | |
| 202 | 202 | if (CollectionUtils.isEmpty(orderIds)) { |
| 203 | 203 | return Collections.emptyList(); |
| 204 | 204 | } |
| 205 | 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 | 213 | return getBaseMapper().selectList(queryWrapper); |
| 210 | 214 | } |
| ... | ... | @@ -266,6 +270,18 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde |
| 266 | 270 | } |
| 267 | 271 | |
| 268 | 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 | 285 | public void cleanCacheByKey(Serializable key) { |
| 270 | 286 | |
| 271 | 287 | } | ... | ... |
| ... | ... | @@ -23,14 +23,17 @@ import com.lframework.xingyun.sc.mappers.ShipmentsPlanDetailMapper; |
| 23 | 23 | import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; |
| 24 | 24 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; |
| 25 | 25 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService; |
| 26 | +import com.lframework.xingyun.sc.utils.CommonUtil; | |
| 26 | 27 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; |
| 27 | 28 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; |
| 29 | +import com.lframework.xingyun.sc.vo.shipments.plan.ShipmentsPlanDetailSplitVo; | |
| 28 | 30 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; |
| 29 | 31 | import org.apache.commons.collections4.CollectionUtils; |
| 30 | 32 | import org.springframework.stereotype.Service; |
| 31 | 33 | import org.springframework.transaction.annotation.Transactional; |
| 32 | 34 | |
| 33 | 35 | import javax.annotation.Resource; |
| 36 | +import java.math.BigDecimal; | |
| 34 | 37 | import java.time.LocalDate; |
| 35 | 38 | import java.util.ArrayList; |
| 36 | 39 | import java.util.List; |
| ... | ... | @@ -148,7 +151,7 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP |
| 148 | 151 | .select(ShipmentsPlanDetail::getOrderSpecId); |
| 149 | 152 | List<ShipmentsPlanDetail> shipmentsPlanDetails = getBaseMapper().selectList(queryWrapper); |
| 150 | 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 | 155 | vo.setOrderSpecIds(orderSpecIds); |
| 153 | 156 | } |
| 154 | 157 | // 开启分页 |
| ... | ... | @@ -157,4 +160,75 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP |
| 157 | 160 | |
| 158 | 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 | 66 | /** |
| 67 | 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 | 99 | * @param orderId 订货单ID |
| 99 | 100 | */ |
| 100 | 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 | 2 | |
| 3 | 3 | import com.lframework.xingyun.sc.vo.shipments.plan.CreateShipmentsPlanDetailVo; |
| 4 | 4 | import com.lframework.xingyun.sc.vo.shipments.plan.QueryShipmentsPlanDetailVo; |
| 5 | +import com.lframework.xingyun.sc.vo.shipments.plan.ShipmentsPlanDetailSplitVo; | |
| 5 | 6 | import com.lframework.xingyun.sc.vo.shipments.plan.UpdateShipmentsPlanDetailVo; |
| 6 | 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 | 8 | import com.lframework.starter.web.core.service.BaseMpService; |
| 10 | 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 | 10 | import java.util.List; |
| 32 | 11 | |
| 33 | 12 | /** |
| ... | ... | @@ -82,4 +61,11 @@ public interface ShipmentsPlanDetailService extends BaseMpService<ShipmentsPlanD |
| 82 | 61 | * @return PageResult<ShipmentsPlanDetail> |
| 83 | 62 | */ |
| 84 | 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 | 180 | tb.revoke_status='PARTIAL') |
| 181 | 181 | AND (tb.status='ISSUED' OR tb.status='WAIT' OR tb.status='TRANSIT') |
| 182 | 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 | 184 | </when> |
| 185 | 185 | <when test="vo.queryType == 'CHANGE'"> |
| 186 | 186 | AND tb.examine_status = 'PASS' |
| 187 | 187 | AND tb.status != 'SHIPPED' |
| 188 | 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 | 190 | </when> |
| 190 | 191 | <otherwise> |
| 191 | 192 | AND 1 = 0 <!-- 确保查询不到任何数据 --> | ... | ... |
| ... | ... | @@ -65,6 +65,7 @@ |
| 65 | 65 | <select id="query" resultMap="PurchaseOrderLine"> |
| 66 | 66 | <include refid="PurchaseOrderLine_sql"/> |
| 67 | 67 | <where> |
| 68 | + and tb.del_flag = false | |
| 68 | 69 | <if test="vo.purchaseOrderId != null and vo.purchaseOrderId != ''"> |
| 69 | 70 | AND tb.purchase_order_id = #{vo.purchaseOrderId} |
| 70 | 71 | </if> |
| ... | ... | @@ -89,7 +90,7 @@ |
| 89 | 90 | length, length_tol_pos, length_tol_neg, |
| 90 | 91 | status, quantity, sales_price, delivery_date, show_order, |
| 91 | 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 | 94 | ) VALUES |
| 94 | 95 | <foreach collection="specList" item="item" separator=","> |
| 95 | 96 | ( |
| ... | ... | @@ -99,7 +100,7 @@ |
| 99 | 100 | #{item.length}, #{item.lengthTolPos}, #{item.lengthTolNeg}, |
| 100 | 101 | #{item.status}, #{item.quantity}, #{item.salesPrice}, #{item.deliveryDate}, #{item.showOrder}, |
| 101 | 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 | 105 | </foreach> |
| 105 | 106 | </insert> | ... | ... |
| ... | ... | @@ -61,12 +61,13 @@ |
| 61 | 61 | INNER JOIN shipments_plan p ON tb.plan_id = p.id |
| 62 | 62 | LEFT JOIN purchase_order_info o ON tb.order_id = o.id |
| 63 | 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 | 65 | </sql> |
| 66 | 66 | |
| 67 | 67 | <select id="query" resultMap="ShipmentsPlanDetail"> |
| 68 | 68 | <include refid="ShipmentsPlanDetail_sql"/> |
| 69 | 69 | <where> |
| 70 | + and tb.del_flag = false | |
| 70 | 71 | <if test="vo.planId != null and vo.planId != ''"> |
| 71 | 72 | AND tb.plan_id = #{vo.planId} |
| 72 | 73 | </if> | ... | ... |