Showing
15 changed files
with
254 additions
and
2 deletions
| @@ -2596,3 +2596,7 @@ ALTER TABLE procurement_weighing_ticket_apply_line | @@ -2596,3 +2596,7 @@ ALTER TABLE procurement_weighing_ticket_apply_line | ||
| 2596 | -- 过磅码单主表:新增完成时间(第一次上传签字凭证时间) | 2596 | -- 过磅码单主表:新增完成时间(第一次上传签字凭证时间) |
| 2597 | ALTER TABLE procurement_weighing_ticket | 2597 | ALTER TABLE procurement_weighing_ticket |
| 2598 | ADD COLUMN complete_time datetime DEFAULT NULL COMMENT '完成时间(第一次上传签字凭证时间)'; | 2598 | ADD COLUMN complete_time datetime DEFAULT NULL COMMENT '完成时间(第一次上传签字凭证时间)'; |
| 2599 | + | ||
| 2600 | +-- 采购计划:差值标识(审核通过初始化为"少 总数量吨",过磅码单完成/作废时重算,供应管理科主管可手动修改) | ||
| 2601 | +ALTER TABLE procurement_plan | ||
| 2602 | + ADD COLUMN diff_quantity_flag varchar(50) DEFAULT NULL COMMENT '差值标识(多x吨/少x吨,null=差值在容差范围内不显示)'; |
| @@ -246,10 +246,16 @@ public class GetProcurementPlanBo extends BaseBo<ProcurementPlan> { | @@ -246,10 +246,16 @@ public class GetProcurementPlanBo extends BaseBo<ProcurementPlan> { | ||
| 246 | /** | 246 | /** |
| 247 | * 数量合计 | 247 | * 数量合计 |
| 248 | */ | 248 | */ |
| 249 | - @ApiModelProperty("数量合计") | 249 | + @ApiModelProperty("数量合计(吨)") |
| 250 | private BigDecimal totalQuantity; | 250 | private BigDecimal totalQuantity; |
| 251 | 251 | ||
| 252 | /** | 252 | /** |
| 253 | + * 差值标识(多x吨/少x吨,null=差值在容差范围内不显示) | ||
| 254 | + */ | ||
| 255 | + @ApiModelProperty("差值标识(多x吨/少x吨,null=差值在容差范围内不显示)") | ||
| 256 | + private String diffQuantityFlag; | ||
| 257 | + | ||
| 258 | + /** | ||
| 253 | * 备注 | 259 | * 备注 |
| 254 | */ | 260 | */ |
| 255 | @ApiModelProperty("备注") | 261 | @ApiModelProperty("备注") |
| 1 | +package com.lframework.xingyun.sc.dto; | ||
| 2 | + | ||
| 3 | +import java.io.Serializable; | ||
| 4 | +import java.math.BigDecimal; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 采购计划已过磅数量聚合结果(公斤) | ||
| 9 | + */ | ||
| 10 | +@Data | ||
| 11 | +public class PlanWeighedQuantityDto implements Serializable { | ||
| 12 | + | ||
| 13 | + private static final long serialVersionUID = 1L; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 采购计划ID | ||
| 17 | + */ | ||
| 18 | + private String planId; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 已过磅数量合计(公斤) | ||
| 22 | + */ | ||
| 23 | + private BigDecimal totalQuantity; | ||
| 24 | +} |
| @@ -21,6 +21,7 @@ import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApp | @@ -21,6 +21,7 @@ import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApp | ||
| 21 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; | 21 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; |
| 22 | import com.lframework.xingyun.sc.procurement.vo.plan.CreateProcurementPlanVo; | 22 | import com.lframework.xingyun.sc.procurement.vo.plan.CreateProcurementPlanVo; |
| 23 | import com.lframework.xingyun.sc.procurement.vo.plan.QueryProcurementPlanVo; | 23 | import com.lframework.xingyun.sc.procurement.vo.plan.QueryProcurementPlanVo; |
| 24 | +import com.lframework.xingyun.sc.procurement.vo.plan.UpdatePlanDiffFlagVo; | ||
| 24 | import com.lframework.xingyun.sc.procurement.vo.plan.UpdateProcurementPlanVo; | 25 | import com.lframework.xingyun.sc.procurement.vo.plan.UpdateProcurementPlanVo; |
| 25 | import com.lframework.xingyun.sc.utils.ExcelUtil; | 26 | import com.lframework.xingyun.sc.utils.ExcelUtil; |
| 26 | import io.swagger.annotations.Api; | 27 | import io.swagger.annotations.Api; |
| @@ -158,6 +159,17 @@ public class ProcurementPlanController extends DefaultBaseController { | @@ -158,6 +159,17 @@ public class ProcurementPlanController extends DefaultBaseController { | ||
| 158 | } | 159 | } |
| 159 | 160 | ||
| 160 | /** | 161 | /** |
| 162 | + * 修改差值标识(供应管理科主管手动更改,传空清除) | ||
| 163 | + */ | ||
| 164 | + @ApiOperation("修改差值标识(供应管理科主管)") | ||
| 165 | + @HasPermission({"plan-manage:domestic-plan:updateDiffFlag"}) | ||
| 166 | + @PutMapping("/diffFlag") | ||
| 167 | + public InvokeResult<Void> updateDiffFlag(@RequestBody @Valid UpdatePlanDiffFlagVo vo) { | ||
| 168 | + procurementPlanService.updateDiffFlag(vo.getId(), vo.getDiffQuantityFlag()); | ||
| 169 | + return InvokeResultBuilder.success(); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + /** | ||
| 161 | * 创建 | 173 | * 创建 |
| 162 | */ | 174 | */ |
| 163 | @ApiOperation("创建") | 175 | @ApiOperation("创建") |
| @@ -214,6 +214,11 @@ public class ProcurementPlan extends BaseEntity implements BaseDto { | @@ -214,6 +214,11 @@ public class ProcurementPlan extends BaseEntity implements BaseDto { | ||
| 214 | private BigDecimal totalQuantity; | 214 | private BigDecimal totalQuantity; |
| 215 | 215 | ||
| 216 | /** | 216 | /** |
| 217 | + * 差值标识(多x吨/少x吨,null=差值在容差范围内不显示;审核通过初始化,过磅码单完成/作废时重算,供应管理科主管可手动修改) | ||
| 218 | + */ | ||
| 219 | + private String diffQuantityFlag; | ||
| 220 | + | ||
| 221 | + /** | ||
| 217 | * 备注 | 222 | * 备注 |
| 218 | */ | 223 | */ |
| 219 | private String remark; | 224 | private String remark; |
| @@ -157,6 +157,8 @@ public class ProcurementPlanChangeServiceImpl extends | @@ -157,6 +157,8 @@ public class ProcurementPlanChangeServiceImpl extends | ||
| 157 | .set(ProcurementPlan::getPlanType, "变") | 157 | .set(ProcurementPlan::getPlanType, "变") |
| 158 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); | 158 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); |
| 159 | procurementPlanService.update(parentWrapper); | 159 | procurementPlanService.update(parentWrapper); |
| 160 | + // 子计划变更完成(流程状态已完成):重算差值标识 | ||
| 161 | + procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId())); | ||
| 160 | //修改分厂 | 162 | //修改分厂 |
| 161 | Wrapper<ProcurementPlanLine> lineWrapper = Wrappers.lambdaUpdate(ProcurementPlanLine.class) | 163 | Wrapper<ProcurementPlanLine> lineWrapper = Wrappers.lambdaUpdate(ProcurementPlanLine.class) |
| 162 | .set(ProcurementPlanLine::getWorkshopId, vo.getLines().get(0).getWorkshopId()) | 164 | .set(ProcurementPlanLine::getWorkshopId, vo.getLines().get(0).getWorkshopId()) |
| @@ -193,6 +195,8 @@ public class ProcurementPlanChangeServiceImpl extends | @@ -193,6 +195,8 @@ public class ProcurementPlanChangeServiceImpl extends | ||
| 193 | .set(ProcurementPlan::getPlanType, planType) | 195 | .set(ProcurementPlan::getPlanType, planType) |
| 194 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); | 196 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); |
| 195 | procurementPlanService.update(parentWrapper); | 197 | procurementPlanService.update(parentWrapper); |
| 198 | + // 主计划变更完成(流程状态已完成):重算差值标识 | ||
| 199 | + procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId())); | ||
| 196 | //修改含运到厂价、修改主计划明细表开票品名 | 200 | //修改含运到厂价、修改主计划明细表开票品名 |
| 197 | List<ProcurementPlanLine> lineList = procurementPlanLineService.list( | 201 | List<ProcurementPlanLine> lineList = procurementPlanLineService.list( |
| 198 | Wrappers.lambdaQuery(ProcurementPlanLine.class) | 202 | Wrappers.lambdaQuery(ProcurementPlanLine.class) |
| @@ -221,6 +225,9 @@ public class ProcurementPlanChangeServiceImpl extends | @@ -221,6 +225,9 @@ public class ProcurementPlanChangeServiceImpl extends | ||
| 221 | .eq(ProcurementPlan::getFrozen, false) | 225 | .eq(ProcurementPlan::getFrozen, false) |
| 222 | .eq(ProcurementPlan::getParentId, vo.getProcurementPlanId()); | 226 | .eq(ProcurementPlan::getParentId, vo.getProcurementPlanId()); |
| 223 | procurementPlanService.update(sonWrapper); | 227 | procurementPlanService.update(sonWrapper); |
| 228 | + // 子计划变更完成(流程状态已完成):重算差值标识 | ||
| 229 | + procurementPlanService.recalcDiffFlags(list.stream() | ||
| 230 | + .map(ProcurementPlan::getId).collect(Collectors.toList())); | ||
| 224 | 231 | ||
| 225 | //先修改子计划中明细表开票品名数据 | 232 | //先修改子计划中明细表开票品名数据 |
| 226 | for (ProcurementPlan procurementPlan : list) { | 233 | for (ProcurementPlan procurementPlan : list) { |
| @@ -269,6 +276,8 @@ public class ProcurementPlanChangeServiceImpl extends | @@ -269,6 +276,8 @@ public class ProcurementPlanChangeServiceImpl extends | ||
| 269 | .set(ProcurementPlan::getProcessNode, null) | 276 | .set(ProcurementPlan::getProcessNode, null) |
| 270 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); | 277 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); |
| 271 | procurementPlanService.update(parentWrapper); | 278 | procurementPlanService.update(parentWrapper); |
| 279 | + // 主计划变更完成(流程状态已完成):重算差值标识 | ||
| 280 | + procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId())); | ||
| 272 | //修改含运到厂价、开票品名 | 281 | //修改含运到厂价、开票品名 |
| 273 | List<ProcurementPlanLine> lineList = procurementPlanLineService.list( | 282 | List<ProcurementPlanLine> lineList = procurementPlanLineService.list( |
| 274 | Wrappers.lambdaQuery(ProcurementPlanLine.class) | 283 | Wrappers.lambdaQuery(ProcurementPlanLine.class) |
| @@ -752,6 +761,9 @@ public class ProcurementPlanChangeServiceImpl extends | @@ -752,6 +761,9 @@ public class ProcurementPlanChangeServiceImpl extends | ||
| 752 | .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now()) | 761 | .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now()) |
| 753 | .eq(ProcurementPlan::getId, planId)); | 762 | .eq(ProcurementPlan::getId, planId)); |
| 754 | 763 | ||
| 764 | + // 主计划变更完成(流程状态已完成):重算差值标识 | ||
| 765 | + procurementPlanService.recalcDiffFlags(Collections.singletonList(planId)); | ||
| 766 | + | ||
| 755 | //作废合同 | 767 | //作废合同 |
| 756 | procurementContractService.deleteById(planId); | 768 | procurementContractService.deleteById(planId); |
| 757 | //生成新合同 | 769 | //生成新合同 |
| @@ -35,7 +35,9 @@ import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; | @@ -35,7 +35,9 @@ import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; | ||
| 35 | import com.lframework.xingyun.sc.procurement.dto.DomesticReviewerDto; | 35 | import com.lframework.xingyun.sc.procurement.dto.DomesticReviewerDto; |
| 36 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; | 36 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; |
| 37 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine; | 37 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine; |
| 38 | +import com.lframework.xingyun.sc.dto.PlanWeighedQuantityDto; | ||
| 38 | import com.lframework.xingyun.sc.procurement.mappers.plan.ProcurementPlanMapper; | 39 | import com.lframework.xingyun.sc.procurement.mappers.plan.ProcurementPlanMapper; |
| 40 | +import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementWeighingTicketMapper; | ||
| 39 | import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService; | 41 | import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService; |
| 40 | import com.lframework.xingyun.sc.procurement.service.contract.ProcurementContractService; | 42 | import com.lframework.xingyun.sc.procurement.service.contract.ProcurementContractService; |
| 41 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService; | 43 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService; |
| @@ -81,6 +83,8 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -81,6 +83,8 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 81 | @Resource | 83 | @Resource |
| 82 | private FlowTaskWrapperMapper flowTaskWrapperMapper; | 84 | private FlowTaskWrapperMapper flowTaskWrapperMapper; |
| 83 | @Resource | 85 | @Resource |
| 86 | + private ProcurementWeighingTicketMapper procurementWeighingTicketMapper; | ||
| 87 | + @Resource | ||
| 84 | private SysRoleService sysRoleService; | 88 | private SysRoleService sysRoleService; |
| 85 | @Resource | 89 | @Resource |
| 86 | private SalesmanQuotationService salesmanQuotationService; | 90 | private SalesmanQuotationService salesmanQuotationService; |
| @@ -583,6 +587,11 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -583,6 +587,11 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 583 | .eq(ProcurementPlan::getId, id); | 587 | .eq(ProcurementPlan::getId, id); |
| 584 | getBaseMapper().update(wrapper); | 588 | getBaseMapper().update(wrapper); |
| 585 | 589 | ||
| 590 | + // 计划流程状态变为已完成:重算差值标识(无过磅记录时即"少 总数量吨") | ||
| 591 | + if ("PASS".equals(approvalStatus)) { | ||
| 592 | + recalcDiffFlags(Collections.singletonList(id)); | ||
| 593 | + } | ||
| 594 | + | ||
| 586 | //如果是子计划且审核通过,检查主计划下所有子计划是否都已通过 | 595 | //如果是子计划且审核通过,检查主计划下所有子计划是否都已通过 |
| 587 | if ("PASS".equals(approvalStatus)) { | 596 | if ("PASS".equals(approvalStatus)) { |
| 588 | 597 | ||
| @@ -605,6 +614,9 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -605,6 +614,9 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 605 | .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now()) | 614 | .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now()) |
| 606 | .eq(ProcurementPlan::getId, parentId); | 615 | .eq(ProcurementPlan::getId, parentId); |
| 607 | getBaseMapper().update(parentWrapper); | 616 | getBaseMapper().update(parentWrapper); |
| 617 | + | ||
| 618 | + // 主计划流程状态变为已完成:重算差值标识 | ||
| 619 | + recalcDiffFlags(Collections.singletonList(parentId)); | ||
| 608 | } | 620 | } |
| 609 | } | 621 | } |
| 610 | } | 622 | } |
| @@ -612,6 +624,72 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -612,6 +624,72 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 612 | 624 | ||
| 613 | @Transactional(rollbackFor = Exception.class) | 625 | @Transactional(rollbackFor = Exception.class) |
| 614 | @Override | 626 | @Override |
| 627 | + public void recalcDiffFlags(List<String> planIds) { | ||
| 628 | + if (CollectionUtil.isEmpty(planIds)) { | ||
| 629 | + return; | ||
| 630 | + } | ||
| 631 | + | ||
| 632 | + List<String> distinctIds = planIds.stream().filter(StringUtils::isNotBlank).distinct() | ||
| 633 | + .collect(Collectors.toList()); | ||
| 634 | + if (CollectionUtil.isEmpty(distinctIds)) { | ||
| 635 | + return; | ||
| 636 | + } | ||
| 637 | + | ||
| 638 | + List<ProcurementPlan> plans = this.listByIds(distinctIds); | ||
| 639 | + if (CollectionUtil.isEmpty(plans)) { | ||
| 640 | + return; | ||
| 641 | + } | ||
| 642 | + | ||
| 643 | + // 已过磅数量合计(公斤),仅统计未作废且已完成(完成时间不为空)的过磅码单 | ||
| 644 | + List<PlanWeighedQuantityDto> sums = procurementWeighingTicketMapper.sumWeighedQuantityByPlanIds(distinctIds); | ||
| 645 | + Map<String, BigDecimal> sumMap = CollectionUtil.isEmpty(sums) ? new HashMap<>() | ||
| 646 | + : sums.stream().filter(Objects::nonNull) | ||
| 647 | + .collect(Collectors.toMap(PlanWeighedQuantityDto::getPlanId, | ||
| 648 | + dto -> dto.getTotalQuantity() == null ? BigDecimal.ZERO : dto.getTotalQuantity(), | ||
| 649 | + (a, b) -> a)); | ||
| 650 | + | ||
| 651 | + for (ProcurementPlan plan : plans) { | ||
| 652 | + if (plan == null || plan.getTotalQuantity() == null) { | ||
| 653 | + continue; | ||
| 654 | + } | ||
| 655 | + // 差值(吨)= 计划总数量(吨)- 已过磅数量(公斤转吨) | ||
| 656 | + BigDecimal total = plan.getTotalQuantity(); | ||
| 657 | + BigDecimal weighed = sumMap.getOrDefault(plan.getId(), BigDecimal.ZERO).movePointRight(3); | ||
| 658 | + BigDecimal diff = total.subtract(weighed); | ||
| 659 | + | ||
| 660 | + // 容差:计划总数量10吨以内差值1吨、10吨以上差值2吨;差值绝对值在容差内不显示 | ||
| 661 | + BigDecimal tolerance = total.compareTo(BigDecimal.TEN) <= 0 ? BigDecimal.ONE : BigDecimal.valueOf(2); | ||
| 662 | + String flag = null; | ||
| 663 | + if (diff.abs().compareTo(tolerance) > 0) { | ||
| 664 | + flag = (diff.signum() > 0 ? "少 " : "多 ") + diff.abs().stripTrailingZeros().toPlainString() + "吨"; | ||
| 665 | + } | ||
| 666 | + | ||
| 667 | + this.update(Wrappers.lambdaUpdate(ProcurementPlan.class) | ||
| 668 | + .set(ProcurementPlan::getDiffQuantityFlag, flag) | ||
| 669 | + .eq(ProcurementPlan::getId, plan.getId())); | ||
| 670 | + } | ||
| 671 | + } | ||
| 672 | + | ||
| 673 | + @Transactional(rollbackFor = Exception.class) | ||
| 674 | + @Override | ||
| 675 | + public void updateDiffFlag(String id, String diffQuantityFlag) { | ||
| 676 | + if (StringUtils.isBlank(id)) { | ||
| 677 | + throw new DefaultClientException("采购计划ID不能为空!"); | ||
| 678 | + } | ||
| 679 | + ProcurementPlan plan = this.getById(id); | ||
| 680 | + if (plan == null) { | ||
| 681 | + throw new DefaultClientException("采购计划不存在!"); | ||
| 682 | + } | ||
| 683 | + | ||
| 684 | + // 传空表示清除标识(显式 set null,避免 MyBatis-Plus NOT_NULL 策略忽略) | ||
| 685 | + getBaseMapper().update(Wrappers.lambdaUpdate(ProcurementPlan.class) | ||
| 686 | + .set(ProcurementPlan::getDiffQuantityFlag, | ||
| 687 | + StringUtils.isBlank(diffQuantityFlag) ? null : diffQuantityFlag.trim()) | ||
| 688 | + .eq(ProcurementPlan::getId, id)); | ||
| 689 | + } | ||
| 690 | + | ||
| 691 | + @Transactional(rollbackFor = Exception.class) | ||
| 692 | + @Override | ||
| 615 | public void updateExamine(String id) { | 693 | public void updateExamine(String id) { |
| 616 | if (StringUtils.isBlank(id)) { | 694 | if (StringUtils.isBlank(id)) { |
| 617 | throw new DefaultClientException("采购计划ID不能为空!"); | 695 | throw new DefaultClientException("采购计划ID不能为空!"); |
| @@ -567,6 +567,13 @@ public class ProcurementPlanReplenishServiceImpl | @@ -567,6 +567,13 @@ public class ProcurementPlanReplenishServiceImpl | ||
| 567 | procurementPlanService.createSubPlan(subVo); | 567 | procurementPlanService.createSubPlan(subVo); |
| 568 | } | 568 | } |
| 569 | } | 569 | } |
| 570 | + | ||
| 571 | + // 补单完成:主计划与子计划流程状态均为已完成,重算差值标识(无过磅记录时即"少 总数量吨") | ||
| 572 | + List<String> diffFlagPlanIds = new ArrayList<>(); | ||
| 573 | + diffFlagPlanIds.add(archivedMain.getId()); | ||
| 574 | + procurementPlanService.listSubPlan(archivedMain.getId()) | ||
| 575 | + .forEach(p -> diffFlagPlanIds.add(p.getId())); | ||
| 576 | + procurementPlanService.recalcDiffFlags(diffFlagPlanIds); | ||
| 570 | } else if ("REFUSE".equals(approvalStatus)) { | 577 | } else if ("REFUSE".equals(approvalStatus)) { |
| 571 | List<SysRole> roles = sysRoleService.getByUserId(entity.getCreateById()); | 578 | List<SysRole> roles = sysRoleService.getByUserId(entity.getCreateById()); |
| 572 | List<String> roleCodes = CollectionUtil.isEmpty(roles) ? new java.util.ArrayList<>() | 579 | List<String> roleCodes = CollectionUtil.isEmpty(roles) ? new java.util.ArrayList<>() |
| @@ -36,6 +36,7 @@ import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighing | @@ -36,6 +36,7 @@ import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighing | ||
| 36 | import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicketPlan; | 36 | import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicketPlan; |
| 37 | import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementWeighingTicketMapper; | 37 | import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementWeighingTicketMapper; |
| 38 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService; | 38 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService; |
| 39 | +import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; | ||
| 39 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketApplyLineService; | 40 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketApplyLineService; |
| 40 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketLineService; | 41 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketLineService; |
| 41 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketPlanService; | 42 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketPlanService; |
| @@ -103,6 +104,8 @@ public class ProcurementWeighingTicketServiceImpl | @@ -103,6 +104,8 @@ public class ProcurementWeighingTicketServiceImpl | ||
| 103 | @Resource | 104 | @Resource |
| 104 | private ProcurementPlanLineService procurementPlanLineService; | 105 | private ProcurementPlanLineService procurementPlanLineService; |
| 105 | @Resource | 106 | @Resource |
| 107 | + private ProcurementPlanService procurementPlanService; | ||
| 108 | + @Resource | ||
| 106 | private FlowInstanceWrapperService flowInstanceWrapperService; | 109 | private FlowInstanceWrapperService flowInstanceWrapperService; |
| 107 | @Resource | 110 | @Resource |
| 108 | private FlowTaskWrapperMapper flowTaskWrapperMapper; | 111 | private FlowTaskWrapperMapper flowTaskWrapperMapper; |
| @@ -329,6 +332,25 @@ public class ProcurementWeighingTicketServiceImpl | @@ -329,6 +332,25 @@ public class ProcurementWeighingTicketServiceImpl | ||
| 329 | 332 | ||
| 330 | @Override | 333 | @Override |
| 331 | @Transactional(rollbackFor = Exception.class) | 334 | @Transactional(rollbackFor = Exception.class) |
| 335 | + public void recalcPlanDiffFlags(List<String> planIds) { | ||
| 336 | + // 计算逻辑统一收敛在采购计划侧(避免多处维护口径) | ||
| 337 | + procurementPlanService.recalcDiffFlags(planIds); | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + /** | ||
| 341 | + * 收集过磅码单关联的采购计划ID(去重去空白) | ||
| 342 | + */ | ||
| 343 | + private List<String> collectPlanIdsByTicketId(String ticketId) { | ||
| 344 | + List<ProcurementWeighingTicketPlan> plans = planLineService.getByWeighingTicketId(ticketId); | ||
| 345 | + if (CollectionUtil.isEmpty(plans)) { | ||
| 346 | + return new ArrayList<>(); | ||
| 347 | + } | ||
| 348 | + return plans.stream().map(ProcurementWeighingTicketPlan::getProcurementPlanId) | ||
| 349 | + .filter(StringUtil::isNotBlank).distinct().collect(Collectors.toList()); | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + @Override | ||
| 353 | + @Transactional(rollbackFor = Exception.class) | ||
| 332 | @OpLog(type = OtherOpLogType.class, name = "上传过磅码单签字凭证,ID:{}", params = {"#id"}) | 354 | @OpLog(type = OtherOpLogType.class, name = "上传过磅码单签字凭证,ID:{}", params = {"#id"}) |
| 333 | public void uploadSignAttachment(String id, String fileIds, String fileNames) { | 355 | public void uploadSignAttachment(String id, String fileIds, String fileNames) { |
| 334 | Assert.notBlank(id); | 356 | Assert.notBlank(id); |
| @@ -350,12 +372,18 @@ public class ProcurementWeighingTicketServiceImpl | @@ -350,12 +372,18 @@ public class ProcurementWeighingTicketServiceImpl | ||
| 350 | .eq(ProcurementWeighingTicket::getId, id); | 372 | .eq(ProcurementWeighingTicket::getId, id); |
| 351 | 373 | ||
| 352 | // 完成时间:以第一次上传签字凭证的时间为准 | 374 | // 完成时间:以第一次上传签字凭证的时间为准 |
| 353 | - if (entity.getCompleteTime() == null) { | 375 | + boolean firstSign = entity.getCompleteTime() == null; |
| 376 | + if (firstSign) { | ||
| 354 | wrapper.set(ProcurementWeighingTicket::getCompleteTime, LocalDateTime.now()); | 377 | wrapper.set(ProcurementWeighingTicket::getCompleteTime, LocalDateTime.now()); |
| 355 | } | 378 | } |
| 356 | 379 | ||
| 357 | this.update(wrapper); | 380 | this.update(wrapper); |
| 358 | 381 | ||
| 382 | + // 首次完成(第一次上传签字凭证)后重算关联采购计划的差值标识 | ||
| 383 | + if (firstSign) { | ||
| 384 | + recalcPlanDiffFlags(collectPlanIdsByTicketId(id)); | ||
| 385 | + } | ||
| 386 | + | ||
| 359 | OpLogUtil.setVariable("id", id); | 387 | OpLogUtil.setVariable("id", id); |
| 360 | OpLogUtil.setExtra(entity); | 388 | OpLogUtil.setExtra(entity); |
| 361 | } | 389 | } |
| @@ -428,6 +456,9 @@ public class ProcurementWeighingTicketServiceImpl | @@ -428,6 +456,9 @@ public class ProcurementWeighingTicketServiceImpl | ||
| 428 | .set(ProcurementWeighingTicket::getDeleted, true) | 456 | .set(ProcurementWeighingTicket::getDeleted, true) |
| 429 | .eq(ProcurementWeighingTicket::getId, id)); | 457 | .eq(ProcurementWeighingTicket::getId, id)); |
| 430 | 458 | ||
| 459 | + // 作废后重算关联采购计划的差值标识(该码单的过磅数量不再纳入计算) | ||
| 460 | + recalcPlanDiffFlags(collectPlanIdsByTicketId(id)); | ||
| 461 | + | ||
| 431 | OpLogUtil.setVariable("id", id); | 462 | OpLogUtil.setVariable("id", id); |
| 432 | OpLogUtil.setExtra(entity); | 463 | OpLogUtil.setExtra(entity); |
| 433 | } | 464 | } |
| @@ -2,6 +2,7 @@ package com.lframework.xingyun.sc.procurement.mappers.weighing; | @@ -2,6 +2,7 @@ package com.lframework.xingyun.sc.procurement.mappers.weighing; | ||
| 2 | 2 | ||
| 3 | import com.lframework.starter.web.core.mapper.BaseMapper; | 3 | import com.lframework.starter.web.core.mapper.BaseMapper; |
| 4 | import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo; | 4 | import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo; |
| 5 | +import com.lframework.xingyun.sc.dto.PlanWeighedQuantityDto; | ||
| 5 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; | 6 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; |
| 6 | import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicket; | 7 | import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicket; |
| 7 | import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementWeighingTicketVo; | 8 | import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementWeighingTicketVo; |
| @@ -33,4 +34,10 @@ public interface ProcurementWeighingTicketMapper extends BaseMapper<ProcurementW | @@ -33,4 +34,10 @@ public interface ProcurementWeighingTicketMapper extends BaseMapper<ProcurementW | ||
| 33 | * 条件:未删除、未冻结、流程状态已完成、不在变更中、不在补单中 | 34 | * 条件:未删除、未冻结、流程状态已完成、不在变更中、不在补单中 |
| 34 | */ | 35 | */ |
| 35 | List<WeighingTicketPlanBo> queryWeighingTicketPlans(@Param("vo") QueryWeighingTicketPlanVo vo); | 36 | List<WeighingTicketPlanBo> queryWeighingTicketPlans(@Param("vo") QueryWeighingTicketPlanVo vo); |
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 按采购计划ID聚合已过磅数量(仅统计未作废且已完成,即完成时间不为空的过磅码单;单位:公斤) | ||
| 40 | + * 用于重算采购计划的差值标识(多x吨/少x吨) | ||
| 41 | + */ | ||
| 42 | + List<PlanWeighedQuantityDto> sumWeighedQuantityByPlanIds(@Param("planIds") List<String> planIds); | ||
| 36 | } | 43 | } |
| @@ -144,6 +144,23 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { | @@ -144,6 +144,23 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { | ||
| 144 | */ | 144 | */ |
| 145 | void updateApprovalStatus(String id, String approvalStatus); | 145 | void updateApprovalStatus(String id, String approvalStatus); |
| 146 | 146 | ||
| 147 | + /** | ||
| 148 | + * 重算差值标识(多x吨/少x吨):计划流程状态变为已完成(首次审核通过/变更完成/补单完成)时调用 | ||
| 149 | + * 口径:已过磅数量 = 未作废且已完成(完成时间不为空)的过磅码单的过磅明细数量合计(公斤转吨) | ||
| 150 | + * 差值 = 总数量 - 已过磅数量;总数量10吨以内容差1吨、10吨以上容差2吨,容差内不显示(置空) | ||
| 151 | + * | ||
| 152 | + * @param planIds 采购计划ID集合 | ||
| 153 | + */ | ||
| 154 | + void recalcDiffFlags(List<String> planIds); | ||
| 155 | + | ||
| 156 | + /** | ||
| 157 | + * 修改差值标识(供应管理科主管手动更改,传空清除) | ||
| 158 | + * | ||
| 159 | + * @param id 采购计划ID | ||
| 160 | + * @param diffQuantityFlag 差值标识(多x吨/少x吨) | ||
| 161 | + */ | ||
| 162 | + void updateDiffFlag(String id, String diffQuantityFlag); | ||
| 163 | + | ||
| 147 | void updateExamine(String id); | 164 | void updateExamine(String id); |
| 148 | 165 | ||
| 149 | /** | 166 | /** |
| @@ -59,6 +59,15 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem | @@ -59,6 +59,15 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem | ||
| 59 | void updateApprovalStatus(String id, String approvalStatus); | 59 | void updateApprovalStatus(String id, String approvalStatus); |
| 60 | 60 | ||
| 61 | /** | 61 | /** |
| 62 | + * 重算采购计划差值标识(多x吨/少x吨) | ||
| 63 | + * 口径:已过磅数量 = 关联该计划的、未作废且已完成(完成时间不为空)的过磅码单的过磅明细数量合计(公斤转吨) | ||
| 64 | + * 差值 = 计划总数量 - 已过磅数量;计划总数量10吨以内容差1吨、10吨以上容差2吨,差值绝对值在容差内不显示 | ||
| 65 | + * | ||
| 66 | + * @param planIds 采购计划ID集合 | ||
| 67 | + */ | ||
| 68 | + void recalcPlanDiffFlags(List<String> planIds); | ||
| 69 | + | ||
| 70 | + /** | ||
| 62 | * 上传签字凭证(可多次,首次上传时锁定过磅重量) | 71 | * 上传签字凭证(可多次,首次上传时锁定过磅重量) |
| 63 | */ | 72 | */ |
| 64 | void uploadSignAttachment(String id, String fileIds, String fileNames); | 73 | void uploadSignAttachment(String id, String fileIds, String fileNames); |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/procurement/vo/plan/UpdatePlanDiffFlagVo.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.procurement.vo.plan; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.io.Serializable; | ||
| 8 | +import javax.validation.constraints.NotBlank; | ||
| 9 | + | ||
| 10 | +@Data | ||
| 11 | +@ApiModel("修改采购计划差值标识Vo") | ||
| 12 | +public class UpdatePlanDiffFlagVo implements Serializable { | ||
| 13 | + | ||
| 14 | + private static final long serialVersionUID = 1L; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty("采购计划ID") | ||
| 17 | + @NotBlank(message = "采购计划ID不能为空!") | ||
| 18 | + private String id; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty("差值标识(多x吨/少x吨,传空清除标识)") | ||
| 21 | + private String diffQuantityFlag; | ||
| 22 | +} |
| @@ -41,6 +41,7 @@ | @@ -41,6 +41,7 @@ | ||
| 41 | <result column="coordination_reason" property="coordinationReason"/> | 41 | <result column="coordination_reason" property="coordinationReason"/> |
| 42 | <result column="invoice_type_status" property="invoiceTypeStatus"/> | 42 | <result column="invoice_type_status" property="invoiceTypeStatus"/> |
| 43 | <result column="total_quantity" property="totalQuantity"/> | 43 | <result column="total_quantity" property="totalQuantity"/> |
| 44 | + <result column="diff_quantity_flag" property="diffQuantityFlag"/> | ||
| 44 | <result column="remark" property="remark"/> | 45 | <result column="remark" property="remark"/> |
| 45 | <result column="material_condition_enabled" property="materialConditionEnabled"/> | 46 | <result column="material_condition_enabled" property="materialConditionEnabled"/> |
| 46 | <result column="material_condition_copper_rice" property="materialConditionCopperRice"/> | 47 | <result column="material_condition_copper_rice" property="materialConditionCopperRice"/> |
| @@ -118,6 +119,7 @@ | @@ -118,6 +119,7 @@ | ||
| 118 | pp.coordination_reason, | 119 | pp.coordination_reason, |
| 119 | pp.invoice_type_status, | 120 | pp.invoice_type_status, |
| 120 | pp.total_quantity, | 121 | pp.total_quantity, |
| 122 | + pp.diff_quantity_flag, | ||
| 121 | pp.remark, | 123 | pp.remark, |
| 122 | pp.material_condition_enabled, | 124 | pp.material_condition_enabled, |
| 123 | pp.material_condition_copper_rice, | 125 | pp.material_condition_copper_rice, |
| @@ -344,4 +344,20 @@ | @@ -344,4 +344,20 @@ | ||
| 344 | AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL | 344 | AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL |
| 345 | OR pp.replenishment_status = 'REPLENISHED') | 345 | OR pp.replenishment_status = 'REPLENISHED') |
| 346 | </select> | 346 | </select> |
| 347 | + | ||
| 348 | + <!-- 按采购计划ID聚合已过磅数量(仅统计未作废且已完成,即完成时间不为空的过磅码单;单位:公斤) --> | ||
| 349 | + <select id="sumWeighedQuantityByPlanIds" resultType="com.lframework.xingyun.sc.dto.PlanWeighedQuantityDto"> | ||
| 350 | + SELECT | ||
| 351 | + pwtl.procurement_plan_id AS planId, | ||
| 352 | + SUM(pwtl.quantity) AS totalQuantity | ||
| 353 | + FROM procurement_weighing_ticket_line pwtl | ||
| 354 | + INNER JOIN procurement_weighing_ticket pwt ON pwt.id = pwtl.weighing_ticket_id | ||
| 355 | + WHERE pwt.deleted = 0 | ||
| 356 | + AND pwt.complete_time IS NOT NULL | ||
| 357 | + AND pwtl.procurement_plan_id IN | ||
| 358 | + <foreach collection="planIds" open="(" separator="," close=")" item="item"> | ||
| 359 | + #{item} | ||
| 360 | + </foreach> | ||
| 361 | + GROUP BY pwtl.procurement_plan_id | ||
| 362 | + </select> | ||
| 347 | </mapper> | 363 | </mapper> |