Commit 52eaf26b45112b61918ad992bbe5dbbb4e71e3c1

Authored by 房远帅
1 parent 737ac748

采购:过磅码单-计算计划差值

Showing 15 changed files with 254 additions and 2 deletions
... ... @@ -2596,3 +2596,7 @@ ALTER TABLE procurement_weighing_ticket_apply_line
2596 2596 -- 过磅码单主表:新增完成时间(第一次上传签字凭证时间)
2597 2597 ALTER TABLE procurement_weighing_ticket
2598 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 246 /**
247 247 * 数量合计
248 248 */
249   - @ApiModelProperty("数量合计")
  249 + @ApiModelProperty("数量合计(吨)")
250 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 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 21 import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
22 22 import com.lframework.xingyun.sc.procurement.vo.plan.CreateProcurementPlanVo;
23 23 import com.lframework.xingyun.sc.procurement.vo.plan.QueryProcurementPlanVo;
  24 +import com.lframework.xingyun.sc.procurement.vo.plan.UpdatePlanDiffFlagVo;
24 25 import com.lframework.xingyun.sc.procurement.vo.plan.UpdateProcurementPlanVo;
25 26 import com.lframework.xingyun.sc.utils.ExcelUtil;
26 27 import io.swagger.annotations.Api;
... ... @@ -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 175 @ApiOperation("创建")
... ...
... ... @@ -214,6 +214,11 @@ public class ProcurementPlan extends BaseEntity implements BaseDto {
214 214 private BigDecimal totalQuantity;
215 215
216 216 /**
  217 + * 差值标识(多x吨/少x吨,null=差值在容差范围内不显示;审核通过初始化,过磅码单完成/作废时重算,供应管理科主管可手动修改)
  218 + */
  219 + private String diffQuantityFlag;
  220 +
  221 + /**
217 222 * 备注
218 223 */
219 224 private String remark;
... ...
... ... @@ -157,6 +157,8 @@ public class ProcurementPlanChangeServiceImpl extends
157 157 .set(ProcurementPlan::getPlanType, "变")
158 158 .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
159 159 procurementPlanService.update(parentWrapper);
  160 + // 子计划变更完成(流程状态已完成):重算差值标识
  161 + procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId()));
160 162 //修改分厂
161 163 Wrapper<ProcurementPlanLine> lineWrapper = Wrappers.lambdaUpdate(ProcurementPlanLine.class)
162 164 .set(ProcurementPlanLine::getWorkshopId, vo.getLines().get(0).getWorkshopId())
... ... @@ -193,6 +195,8 @@ public class ProcurementPlanChangeServiceImpl extends
193 195 .set(ProcurementPlan::getPlanType, planType)
194 196 .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
195 197 procurementPlanService.update(parentWrapper);
  198 + // 主计划变更完成(流程状态已完成):重算差值标识
  199 + procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId()));
196 200 //修改含运到厂价、修改主计划明细表开票品名
197 201 List<ProcurementPlanLine> lineList = procurementPlanLineService.list(
198 202 Wrappers.lambdaQuery(ProcurementPlanLine.class)
... ... @@ -221,6 +225,9 @@ public class ProcurementPlanChangeServiceImpl extends
221 225 .eq(ProcurementPlan::getFrozen, false)
222 226 .eq(ProcurementPlan::getParentId, vo.getProcurementPlanId());
223 227 procurementPlanService.update(sonWrapper);
  228 + // 子计划变更完成(流程状态已完成):重算差值标识
  229 + procurementPlanService.recalcDiffFlags(list.stream()
  230 + .map(ProcurementPlan::getId).collect(Collectors.toList()));
224 231
225 232 //先修改子计划中明细表开票品名数据
226 233 for (ProcurementPlan procurementPlan : list) {
... ... @@ -269,6 +276,8 @@ public class ProcurementPlanChangeServiceImpl extends
269 276 .set(ProcurementPlan::getProcessNode, null)
270 277 .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
271 278 procurementPlanService.update(parentWrapper);
  279 + // 主计划变更完成(流程状态已完成):重算差值标识
  280 + procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId()));
272 281 //修改含运到厂价、开票品名
273 282 List<ProcurementPlanLine> lineList = procurementPlanLineService.list(
274 283 Wrappers.lambdaQuery(ProcurementPlanLine.class)
... ... @@ -752,6 +761,9 @@ public class ProcurementPlanChangeServiceImpl extends
752 761 .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now())
753 762 .eq(ProcurementPlan::getId, planId));
754 763
  764 + // 主计划变更完成(流程状态已完成):重算差值标识
  765 + procurementPlanService.recalcDiffFlags(Collections.singletonList(planId));
  766 +
755 767 //作废合同
756 768 procurementContractService.deleteById(planId);
757 769 //生成新合同
... ...
... ... @@ -35,7 +35,9 @@ import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
35 35 import com.lframework.xingyun.sc.procurement.dto.DomesticReviewerDto;
36 36 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
37 37 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine;
  38 +import com.lframework.xingyun.sc.dto.PlanWeighedQuantityDto;
38 39 import com.lframework.xingyun.sc.procurement.mappers.plan.ProcurementPlanMapper;
  40 +import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementWeighingTicketMapper;
39 41 import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService;
40 42 import com.lframework.xingyun.sc.procurement.service.contract.ProcurementContractService;
41 43 import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService;
... ... @@ -81,6 +83,8 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla
81 83 @Resource
82 84 private FlowTaskWrapperMapper flowTaskWrapperMapper;
83 85 @Resource
  86 + private ProcurementWeighingTicketMapper procurementWeighingTicketMapper;
  87 + @Resource
84 88 private SysRoleService sysRoleService;
85 89 @Resource
86 90 private SalesmanQuotationService salesmanQuotationService;
... ... @@ -583,6 +587,11 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla
583 587 .eq(ProcurementPlan::getId, id);
584 588 getBaseMapper().update(wrapper);
585 589
  590 + // 计划流程状态变为已完成:重算差值标识(无过磅记录时即"少 总数量吨")
  591 + if ("PASS".equals(approvalStatus)) {
  592 + recalcDiffFlags(Collections.singletonList(id));
  593 + }
  594 +
586 595 //如果是子计划且审核通过,检查主计划下所有子计划是否都已通过
587 596 if ("PASS".equals(approvalStatus)) {
588 597
... ... @@ -605,6 +614,9 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla
605 614 .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now())
606 615 .eq(ProcurementPlan::getId, parentId);
607 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 624
613 625 @Transactional(rollbackFor = Exception.class)
614 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 693 public void updateExamine(String id) {
616 694 if (StringUtils.isBlank(id)) {
617 695 throw new DefaultClientException("采购计划ID不能为空!");
... ...
... ... @@ -567,6 +567,13 @@ public class ProcurementPlanReplenishServiceImpl
567 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 577 } else if ("REFUSE".equals(approvalStatus)) {
571 578 List<SysRole> roles = sysRoleService.getByUserId(entity.getCreateById());
572 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 36 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicketPlan;
37 37 import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementWeighingTicketMapper;
38 38 import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService;
  39 +import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
39 40 import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketApplyLineService;
40 41 import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketLineService;
41 42 import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketPlanService;
... ... @@ -103,6 +104,8 @@ public class ProcurementWeighingTicketServiceImpl
103 104 @Resource
104 105 private ProcurementPlanLineService procurementPlanLineService;
105 106 @Resource
  107 + private ProcurementPlanService procurementPlanService;
  108 + @Resource
106 109 private FlowInstanceWrapperService flowInstanceWrapperService;
107 110 @Resource
108 111 private FlowTaskWrapperMapper flowTaskWrapperMapper;
... ... @@ -329,6 +332,25 @@ public class ProcurementWeighingTicketServiceImpl
329 332
330 333 @Override
331 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 354 @OpLog(type = OtherOpLogType.class, name = "上传过磅码单签字凭证,ID:{}", params = {"#id"})
333 355 public void uploadSignAttachment(String id, String fileIds, String fileNames) {
334 356 Assert.notBlank(id);
... ... @@ -350,12 +372,18 @@ public class ProcurementWeighingTicketServiceImpl
350 372 .eq(ProcurementWeighingTicket::getId, id);
351 373
352 374 // 完成时间:以第一次上传签字凭证的时间为准
353   - if (entity.getCompleteTime() == null) {
  375 + boolean firstSign = entity.getCompleteTime() == null;
  376 + if (firstSign) {
354 377 wrapper.set(ProcurementWeighingTicket::getCompleteTime, LocalDateTime.now());
355 378 }
356 379
357 380 this.update(wrapper);
358 381
  382 + // 首次完成(第一次上传签字凭证)后重算关联采购计划的差值标识
  383 + if (firstSign) {
  384 + recalcPlanDiffFlags(collectPlanIdsByTicketId(id));
  385 + }
  386 +
359 387 OpLogUtil.setVariable("id", id);
360 388 OpLogUtil.setExtra(entity);
361 389 }
... ... @@ -428,6 +456,9 @@ public class ProcurementWeighingTicketServiceImpl
428 456 .set(ProcurementWeighingTicket::getDeleted, true)
429 457 .eq(ProcurementWeighingTicket::getId, id));
430 458
  459 + // 作废后重算关联采购计划的差值标识(该码单的过磅数量不再纳入计算)
  460 + recalcPlanDiffFlags(collectPlanIdsByTicketId(id));
  461 +
431 462 OpLogUtil.setVariable("id", id);
432 463 OpLogUtil.setExtra(entity);
433 464 }
... ...
... ... @@ -2,6 +2,7 @@ package com.lframework.xingyun.sc.procurement.mappers.weighing;
2 2
3 3 import com.lframework.starter.web.core.mapper.BaseMapper;
4 4 import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo;
  5 +import com.lframework.xingyun.sc.dto.PlanWeighedQuantityDto;
5 6 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
6 7 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicket;
7 8 import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementWeighingTicketVo;
... ... @@ -33,4 +34,10 @@ public interface ProcurementWeighingTicketMapper extends BaseMapper<ProcurementW
33 34 * 条件:未删除、未冻结、流程状态已完成、不在变更中、不在补单中
34 35 */
35 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 144 */
145 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 164 void updateExamine(String id);
148 165
149 166 /**
... ...
... ... @@ -59,6 +59,15 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem
59 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 73 void uploadSignAttachment(String id, String fileIds, String fileNames);
... ...
  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 41 <result column="coordination_reason" property="coordinationReason"/>
42 42 <result column="invoice_type_status" property="invoiceTypeStatus"/>
43 43 <result column="total_quantity" property="totalQuantity"/>
  44 + <result column="diff_quantity_flag" property="diffQuantityFlag"/>
44 45 <result column="remark" property="remark"/>
45 46 <result column="material_condition_enabled" property="materialConditionEnabled"/>
46 47 <result column="material_condition_copper_rice" property="materialConditionCopperRice"/>
... ... @@ -118,6 +119,7 @@
118 119 pp.coordination_reason,
119 120 pp.invoice_type_status,
120 121 pp.total_quantity,
  122 + pp.diff_quantity_flag,
121 123 pp.remark,
122 124 pp.material_condition_enabled,
123 125 pp.material_condition_copper_rice,
... ...
... ... @@ -344,4 +344,20 @@
344 344 AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL
345 345 OR pp.replenishment_status = 'REPLENISHED')
346 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 363 </mapper>
... ...