Showing
12 changed files
with
47 additions
and
75 deletions
| ... | ... | @@ -63,6 +63,7 @@ |
| 63 | 63 | |
| 64 | 64 | **坑**:只改了 entity,XML resultMap/SELECT、Vo、Bo 漏改,导致查询列缺失或保存丢字段。 |
| 65 | 65 | **正确做法**:按 `skill/.trae/skills/新增字段` 清单走:base.sql(ALTER 追加)→ entity → XML(resultMap+SELECT) → QueryVo/CreateVo/UpdateVo → GetBo;BeanUtil.copyProperties / BaseBo 构造按同名字段自动映射,**字段名必须对齐**。 |
| 66 | +**实证**:diff_quantity_exceeded 上线时实体/Vo/Bo/DDL 全改了,唯独漏了 ProcurementPlanMapper.xml 的 resultMap+SELECT,列表/详情查不出值——XML 自定义查询列是最易漏的一环,加列后 Grep 列名自查 XML 是否覆盖。 | |
| 66 | 67 | |
| 67 | 68 | ## 12. 非持久化展示字段用 @TableField(exist = false) |
| 68 | 69 | ... | ... |
| ... | ... | @@ -2614,7 +2614,11 @@ ALTER TABLE procurement_weighing_ticket |
| 2614 | 2614 | |
| 2615 | 2615 | -- 采购计划:差值标识(审核通过初始化为"少 总数量吨",过磅码单完成/作废时重算,供应管理科主管可手动修改) |
| 2616 | 2616 | ALTER TABLE procurement_plan |
| 2617 | - ADD COLUMN diff_quantity_flag varchar(50) DEFAULT NULL COMMENT '差值标识(多x吨/少x吨,null=差值在容差范围内不显示)'; | |
| 2617 | + ADD COLUMN diff_quantity_flag varchar(50) DEFAULT NULL COMMENT '差值标识(多x吨/少x吨,始终返回)'; | |
| 2618 | + | |
| 2619 | +-- 采购计划:是否超过差值容差(计划总数量10吨以内容差1吨、10吨以上容差2吨;过磅码单变动时重算,供应管理科主管可手动修改) | |
| 2620 | +ALTER TABLE procurement_plan | |
| 2621 | + ADD COLUMN diff_quantity_exceeded tinyint(1) DEFAULT NULL COMMENT '是否超过差值容差(true-超差 false-未超差)'; | |
| 2618 | 2622 | |
| 2619 | 2623 | -- 过磅码单:复磅功能(复磅=新增一张码单关联原单、编号为F+原编号,复磅单审核通过后原码单作废) |
| 2620 | 2624 | ALTER TABLE procurement_weighing_ticket | ... | ... |
| ... | ... | @@ -250,12 +250,18 @@ public class GetProcurementPlanBo extends BaseBo<ProcurementPlan> { |
| 250 | 250 | private BigDecimal totalQuantity; |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * 差值标识(多x吨/少x吨,null=差值在容差范围内不显示) | |
| 253 | + * 差值标识(多x吨/少x吨,始终返回) | |
| 254 | 254 | */ |
| 255 | - @ApiModelProperty("差值标识(多x吨/少x吨,null=差值在容差范围内不显示)") | |
| 255 | + @ApiModelProperty("差值标识(多x吨/少x吨)") | |
| 256 | 256 | private String diffQuantityFlag; |
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | + * 是否超过差值容差(true-超差 false-未超差;计划总数量10吨以内容差1吨、10吨以上容差2吨) | |
| 260 | + */ | |
| 261 | + @ApiModelProperty("是否超过差值容差(true-超差 false-未超差)") | |
| 262 | + private Boolean diffQuantityExceeded; | |
| 263 | + | |
| 264 | + /** | |
| 259 | 265 | * 备注 |
| 260 | 266 | */ |
| 261 | 267 | @ApiModelProperty("备注") | ... | ... |
| ... | ... | @@ -21,7 +21,6 @@ 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; | |
| 25 | 24 | import com.lframework.xingyun.sc.procurement.vo.plan.UpdateProcurementPlanVo; |
| 26 | 25 | import com.lframework.xingyun.sc.utils.ExcelUtil; |
| 27 | 26 | import io.swagger.annotations.Api; |
| ... | ... | @@ -45,6 +44,7 @@ import org.springframework.web.bind.annotation.RestController; |
| 45 | 44 | import javax.servlet.http.HttpServletResponse; |
| 46 | 45 | import javax.validation.Valid; |
| 47 | 46 | import javax.validation.constraints.NotBlank; |
| 47 | +import javax.validation.constraints.NotNull; | |
| 48 | 48 | import java.io.FileNotFoundException; |
| 49 | 49 | import java.io.IOException; |
| 50 | 50 | import java.io.InputStream; |
| ... | ... | @@ -159,13 +159,14 @@ public class ProcurementPlanController extends DefaultBaseController { |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | - * 修改差值标识(供应管理科主管手动更改,传空清除) | |
| 162 | + * 修改是否超过差值(供应管理科主管手动更改;过磅码单变动时会自动重算覆盖) | |
| 163 | 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()); | |
| 164 | + @ApiOperation("修改是否超过差值(供应管理科主管)") | |
| 165 | + @HasPermission({"plan-manage:domestic-plan:change"}) | |
| 166 | + @PutMapping("/diffQuantityExceeded") | |
| 167 | + public InvokeResult<Void> updateDiffQuantityExceeded(@NotBlank(message = "ID不能为空!") String id, | |
| 168 | + @NotNull(message = "diffQuantityExceeded不能为空!") Boolean diffQuantityExceeded) { | |
| 169 | + procurementPlanService.updateDiffQuantityExceeded(id, diffQuantityExceeded); | |
| 169 | 170 | return InvokeResultBuilder.success(); |
| 170 | 171 | } |
| 171 | 172 | ... | ... |
| ... | ... | @@ -214,11 +214,16 @@ public class ProcurementPlan extends BaseEntity implements BaseDto { |
| 214 | 214 | private BigDecimal totalQuantity; |
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | - * 差值标识(多x吨/少x吨,null=差值在容差范围内不显示;审核通过初始化,过磅码单完成/作废时重算,供应管理科主管可手动修改) | |
| 217 | + * 差值标识(多x吨/少x吨,始终返回;审核通过初始化,过磅码单完成/作废时重算,供应管理科主管可手动修改) | |
| 218 | 218 | */ |
| 219 | 219 | private String diffQuantityFlag; |
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | + * 是否超过差值容差(true-超差 false-未超差;计划总数量10吨以内容差1吨、10吨以上容差2吨;过磅码单变动时重算,供应管理科主管可手动修改) | |
| 223 | + */ | |
| 224 | + private Boolean diffQuantityExceeded; | |
| 225 | + | |
| 226 | + /** | |
| 222 | 227 | * 备注 |
| 223 | 228 | */ |
| 224 | 229 | private String remark; | ... | ... |
| ... | ... | @@ -257,8 +257,6 @@ public class ProcurementPlanChangeServiceImpl extends |
| 257 | 257 | .set(ProcurementPlan::getPlanType, "变") |
| 258 | 258 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); |
| 259 | 259 | procurementPlanService.update(parentWrapper); |
| 260 | - // 子计划变更完成(流程状态已完成):重算差值标识 | |
| 261 | - procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId())); | |
| 262 | 260 | //修改分厂 |
| 263 | 261 | Wrapper<ProcurementPlanLine> lineWrapper = Wrappers.lambdaUpdate(ProcurementPlanLine.class) |
| 264 | 262 | .set(ProcurementPlanLine::getWorkshopId, vo.getLines().get(0).getWorkshopId()) |
| ... | ... | @@ -295,8 +293,6 @@ public class ProcurementPlanChangeServiceImpl extends |
| 295 | 293 | .set(ProcurementPlan::getPlanType, planType) |
| 296 | 294 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); |
| 297 | 295 | procurementPlanService.update(parentWrapper); |
| 298 | - // 主计划变更完成(流程状态已完成):重算差值标识 | |
| 299 | - procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId())); | |
| 300 | 296 | //修改含运到厂价、修改主计划明细表开票品名 |
| 301 | 297 | List<ProcurementPlanLine> lineList = procurementPlanLineService.list( |
| 302 | 298 | Wrappers.lambdaQuery(ProcurementPlanLine.class) |
| ... | ... | @@ -325,9 +321,6 @@ public class ProcurementPlanChangeServiceImpl extends |
| 325 | 321 | .eq(ProcurementPlan::getFrozen, false) |
| 326 | 322 | .eq(ProcurementPlan::getParentId, vo.getProcurementPlanId()); |
| 327 | 323 | procurementPlanService.update(sonWrapper); |
| 328 | - // 子计划变更完成(流程状态已完成):重算差值标识 | |
| 329 | - procurementPlanService.recalcDiffFlags(list.stream() | |
| 330 | - .map(ProcurementPlan::getId).collect(Collectors.toList())); | |
| 331 | 324 | |
| 332 | 325 | //先修改子计划中明细表开票品名数据 |
| 333 | 326 | for (ProcurementPlan procurementPlan : list) { |
| ... | ... | @@ -376,8 +369,6 @@ public class ProcurementPlanChangeServiceImpl extends |
| 376 | 369 | .set(ProcurementPlan::getProcessNode, null) |
| 377 | 370 | .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); |
| 378 | 371 | procurementPlanService.update(parentWrapper); |
| 379 | - // 主计划变更完成(流程状态已完成):重算差值标识 | |
| 380 | - procurementPlanService.recalcDiffFlags(Collections.singletonList(vo.getProcurementPlanId())); | |
| 381 | 372 | //修改含运到厂价、开票品名 |
| 382 | 373 | List<ProcurementPlanLine> lineList = procurementPlanLineService.list( |
| 383 | 374 | Wrappers.lambdaQuery(ProcurementPlanLine.class) |
| ... | ... | @@ -861,9 +852,6 @@ public class ProcurementPlanChangeServiceImpl extends |
| 861 | 852 | .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now()) |
| 862 | 853 | .eq(ProcurementPlan::getId, planId)); |
| 863 | 854 | |
| 864 | - // 主计划变更完成(流程状态已完成):重算差值标识 | |
| 865 | - procurementPlanService.recalcDiffFlags(Collections.singletonList(planId)); | |
| 866 | - | |
| 867 | 855 | //作废合同 |
| 868 | 856 | procurementContractService.deleteById(planId); |
| 869 | 857 | //生成新合同 | ... | ... |
| ... | ... | @@ -587,11 +587,6 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla |
| 587 | 587 | .eq(ProcurementPlan::getId, id); |
| 588 | 588 | getBaseMapper().update(wrapper); |
| 589 | 589 | |
| 590 | - // 计划流程状态变为已完成:重算差值标识(无过磅记录时即"少 总数量吨") | |
| 591 | - if ("PASS".equals(approvalStatus)) { | |
| 592 | - recalcDiffFlags(Collections.singletonList(id)); | |
| 593 | - } | |
| 594 | - | |
| 595 | 590 | //如果是子计划且审核通过,检查主计划下所有子计划是否都已通过 |
| 596 | 591 | if ("PASS".equals(approvalStatus)) { |
| 597 | 592 | |
| ... | ... | @@ -614,9 +609,6 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla |
| 614 | 609 | .set(ProcurementPlan::getApprovalPassTime, LocalDateTime.now()) |
| 615 | 610 | .eq(ProcurementPlan::getId, parentId); |
| 616 | 611 | getBaseMapper().update(parentWrapper); |
| 617 | - | |
| 618 | - // 主计划流程状态变为已完成:重算差值标识 | |
| 619 | - recalcDiffFlags(Collections.singletonList(parentId)); | |
| 620 | 612 | } |
| 621 | 613 | } |
| 622 | 614 | } |
| ... | ... | @@ -657,22 +649,23 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla |
| 657 | 649 | BigDecimal weighed = sumMap.getOrDefault(plan.getId(), BigDecimal.ZERO).movePointLeft(3); |
| 658 | 650 | BigDecimal diff = total.subtract(weighed); |
| 659 | 651 | |
| 660 | - // 容差:计划总数量10吨以内差值1吨、10吨以上差值2吨;差值绝对值在容差内不显示 | |
| 652 | + // 容差:计划总数量10吨以内差值1吨、10吨以上差值2吨 | |
| 661 | 653 | 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 | - } | |
| 654 | + boolean exceeded = diff.abs().compareTo(tolerance) > 0; | |
| 655 | + | |
| 656 | + // 差值标识始终返回(多x吨/少x吨),是否超差单独标记 | |
| 657 | + String flag = (diff.signum() > 0 ? "少 " : "多 ") + diff.abs().stripTrailingZeros().toPlainString() + "吨"; | |
| 666 | 658 | |
| 667 | 659 | this.update(Wrappers.lambdaUpdate(ProcurementPlan.class) |
| 668 | 660 | .set(ProcurementPlan::getDiffQuantityFlag, flag) |
| 661 | + .set(ProcurementPlan::getDiffQuantityExceeded, exceeded) | |
| 669 | 662 | .eq(ProcurementPlan::getId, plan.getId())); |
| 670 | 663 | } |
| 671 | 664 | } |
| 672 | 665 | |
| 673 | 666 | @Transactional(rollbackFor = Exception.class) |
| 674 | 667 | @Override |
| 675 | - public void updateDiffFlag(String id, String diffQuantityFlag) { | |
| 668 | + public void updateDiffQuantityExceeded(String id, Boolean diffQuantityExceeded) { | |
| 676 | 669 | if (StringUtils.isBlank(id)) { |
| 677 | 670 | throw new DefaultClientException("采购计划ID不能为空!"); |
| 678 | 671 | } |
| ... | ... | @@ -681,10 +674,9 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla |
| 681 | 674 | throw new DefaultClientException("采购计划不存在!"); |
| 682 | 675 | } |
| 683 | 676 | |
| 684 | - // 传空表示清除标识(显式 set null,避免 MyBatis-Plus NOT_NULL 策略忽略) | |
| 677 | + // 显式 set(null 也写入,避免 MyBatis-Plus NOT_NULL 策略忽略) | |
| 685 | 678 | getBaseMapper().update(Wrappers.lambdaUpdate(ProcurementPlan.class) |
| 686 | - .set(ProcurementPlan::getDiffQuantityFlag, | |
| 687 | - StringUtils.isBlank(diffQuantityFlag) ? null : diffQuantityFlag.trim()) | |
| 679 | + .set(ProcurementPlan::getDiffQuantityExceeded, diffQuantityExceeded) | |
| 688 | 680 | .eq(ProcurementPlan::getId, id)); |
| 689 | 681 | } |
| 690 | 682 | ... | ... |
| ... | ... | @@ -568,12 +568,6 @@ public class ProcurementPlanReplenishServiceImpl |
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 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); | |
| 577 | 571 | } else if ("REFUSE".equals(approvalStatus)) { |
| 578 | 572 | List<SysRole> roles = sysRoleService.getByUserId(entity.getCreateById()); |
| 579 | 573 | List<String> roleCodes = CollectionUtil.isEmpty(roles) ? new java.util.ArrayList<>() | ... | ... |
| ... | ... | @@ -145,21 +145,22 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { |
| 145 | 145 | void updateApprovalStatus(String id, String approvalStatus); |
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | - * 重算差值标识(多x吨/少x吨):计划流程状态变为已完成(首次审核通过/变更完成/补单完成)时调用 | |
| 148 | + * 重算差值标识(多x吨/少x吨):仅在过磅码单第一次完成(首次上传签字凭证记录完成时间)、码单作废、复磅作废原单时调用; | |
| 149 | + * 计划流程完成(首次审核通过/变更完成/补单完成)不计算,差值字段保持为空(或上次计算的值) | |
| 149 | 150 | * 口径:已过磅数量 = 未作废且已完成(完成时间不为空)的过磅码单的过磅明细数量合计(公斤转吨) |
| 150 | - * 差值 = 总数量 - 已过磅数量;总数量10吨以内容差1吨、10吨以上容差2吨,容差内不显示(置空) | |
| 151 | + * 差值 = 总数量 - 已过磅数量;总数量10吨以内容差1吨、10吨以上容差2吨,差值标识始终返回,是否超差单独记录 | |
| 151 | 152 | * |
| 152 | 153 | * @param planIds 采购计划ID集合 |
| 153 | 154 | */ |
| 154 | 155 | void recalcDiffFlags(List<String> planIds); |
| 155 | 156 | |
| 156 | 157 | /** |
| 157 | - * 修改差值标识(供应管理科主管手动更改,传空清除) | |
| 158 | + * 手动修改是否超过差值(供应管理科主管;过磅码单变动时会被自动重算覆盖) | |
| 158 | 159 | * |
| 159 | - * @param id 采购计划ID | |
| 160 | - * @param diffQuantityFlag 差值标识(多x吨/少x吨) | |
| 160 | + * @param id 采购计划ID | |
| 161 | + * @param diffQuantityExceeded 是否超过差值容差 | |
| 161 | 162 | */ |
| 162 | - void updateDiffFlag(String id, String diffQuantityFlag); | |
| 163 | + void updateDiffQuantityExceeded(String id, Boolean diffQuantityExceeded); | |
| 163 | 164 | |
| 164 | 165 | void updateExamine(String id); |
| 165 | 166 | ... | ... |
| ... | ... | @@ -69,7 +69,7 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem |
| 69 | 69 | /** |
| 70 | 70 | * 重算采购计划差值标识(多x吨/少x吨) |
| 71 | 71 | * 口径:已过磅数量 = 关联该计划的、未作废且已完成(完成时间不为空)的过磅码单的过磅明细数量合计(公斤转吨) |
| 72 | - * 差值 = 计划总数量 - 已过磅数量;计划总数量10吨以内容差1吨、10吨以上容差2吨,差值绝对值在容差内不显示 | |
| 72 | + * 差值 = 计划总数量 - 已过磅数量;计划总数量10吨以内容差1吨、10吨以上容差2吨,差值标识始终返回,是否超差单独记录 | |
| 73 | 73 | * |
| 74 | 74 | * @param planIds 采购计划ID集合 |
| 75 | 75 | */ | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/procurement/vo/plan/UpdatePlanDiffFlagVo.java
deleted
100644 → 0
| 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 | -} |
| ... | ... | @@ -42,6 +42,7 @@ |
| 42 | 42 | <result column="invoice_type_status" property="invoiceTypeStatus"/> |
| 43 | 43 | <result column="total_quantity" property="totalQuantity"/> |
| 44 | 44 | <result column="diff_quantity_flag" property="diffQuantityFlag"/> |
| 45 | + <result column="diff_quantity_exceeded" property="diffQuantityExceeded"/> | |
| 45 | 46 | <result column="remark" property="remark"/> |
| 46 | 47 | <result column="material_condition_enabled" property="materialConditionEnabled"/> |
| 47 | 48 | <result column="material_condition_copper_rice" property="materialConditionCopperRice"/> |
| ... | ... | @@ -120,6 +121,7 @@ |
| 120 | 121 | pp.invoice_type_status, |
| 121 | 122 | pp.total_quantity, |
| 122 | 123 | pp.diff_quantity_flag, |
| 124 | + pp.diff_quantity_exceeded, | |
| 123 | 125 | pp.remark, |
| 124 | 126 | pp.material_condition_enabled, |
| 125 | 127 | pp.material_condition_copper_rice, | ... | ... |