Commit fe1f53708a7f93c39316f33845d97d0b37a5fd3e

Authored by 房远帅
1 parent 2bf654c3

采购-入库:增加采购处和区域

... ... @@ -2788,6 +2788,39 @@ ALTER TABLE procurement_material_settle_detail ADD COLUMN gyglkzjy_name VARCHAR(
2788 2788 ALTER TABLE procurement_material_settle_detail ADD COLUMN ckzg_id VARCHAR(32) DEFAULT NULL COMMENT '仓库主管审核人ID(审核通过时记录)';
2789 2789 ALTER TABLE procurement_material_settle_detail ADD COLUMN ckzg_name VARCHAR(64) DEFAULT NULL COMMENT '仓库主管审核人(审核通过时记录)';
2790 2790
  2791 +-- 入库链路六个单据主表统一增加采购处/区域冗余列(数据权限按采购处/区域过滤;前端保证同一码单关联计划同一采购处、区域)
  2792 +ALTER TABLE procurement_weighing_ticket ADD COLUMN purchase_department_id varchar(32) DEFAULT NULL COMMENT '采购处ID(关联采购计划的采购处)';
  2793 +ALTER TABLE procurement_weighing_ticket ADD COLUMN region_id varchar(32) DEFAULT NULL COMMENT '区域ID(关联采购计划的区域)';
  2794 +ALTER TABLE procurement_assay_apply ADD COLUMN purchase_department_id varchar(32) DEFAULT NULL COMMENT '采购处ID(取自过磅码单)';
  2795 +ALTER TABLE procurement_assay_apply ADD COLUMN region_id varchar(32) DEFAULT NULL COMMENT '区域ID(取自过磅码单)';
  2796 +ALTER TABLE procurement_assay_report ADD COLUMN purchase_department_id varchar(32) DEFAULT NULL COMMENT '采购处ID(取自过磅码单)';
  2797 +ALTER TABLE procurement_assay_report ADD COLUMN region_id varchar(32) DEFAULT NULL COMMENT '区域ID(取自过磅码单)';
  2798 +ALTER TABLE procurement_material_settle_detail ADD COLUMN purchase_department_id varchar(32) DEFAULT NULL COMMENT '采购处ID(取自过磅码单)';
  2799 +ALTER TABLE procurement_material_settle_detail ADD COLUMN region_id varchar(32) DEFAULT NULL COMMENT '区域ID(取自过磅码单)';
  2800 +ALTER TABLE procurement_warehouse_receive_order ADD COLUMN purchase_department_id varchar(32) DEFAULT NULL COMMENT '采购处ID(取自原料结算详情单)';
  2801 +ALTER TABLE procurement_warehouse_receive_order ADD COLUMN region_id varchar(32) DEFAULT NULL COMMENT '区域ID(取自原料结算详情单)';
  2802 +
  2803 +-- 存量数据回填:过磅码单从关联的第一个采购计划取采购处/区域
  2804 +UPDATE procurement_weighing_ticket t
  2805 +JOIN (
  2806 + SELECT pwt.weighing_ticket_id, pp.purchase_department, pp.region
  2807 + FROM procurement_weighing_ticket_plan pwt
  2808 + JOIN procurement_plan pp ON pp.id = pwt.procurement_plan_id
  2809 + JOIN (SELECT weighing_ticket_id, MIN(id) AS min_id FROM procurement_weighing_ticket_plan GROUP BY weighing_ticket_id) m
  2810 + ON m.weighing_ticket_id = pwt.weighing_ticket_id AND m.min_id = pwt.id
  2811 +) src ON src.weighing_ticket_id = t.id
  2812 +SET t.purchase_department_id = src.purchase_department, t.region_id = src.region;
  2813 +-- 存量数据回填:化验送样单/化验报告单/原料结算详情单从过磅码单取
  2814 +UPDATE procurement_assay_apply t JOIN procurement_weighing_ticket s ON s.id = t.weighing_ticket_id
  2815 +SET t.purchase_department_id = s.purchase_department_id, t.region_id = s.region_id;
  2816 +UPDATE procurement_assay_report t JOIN procurement_weighing_ticket s ON s.id = t.weighing_ticket_id
  2817 +SET t.purchase_department_id = s.purchase_department_id, t.region_id = s.region_id;
  2818 +UPDATE procurement_material_settle_detail t JOIN procurement_weighing_ticket s ON s.id = t.weighing_ticket_id
  2819 +SET t.purchase_department_id = s.purchase_department_id, t.region_id = s.region_id;
  2820 +-- 存量数据回填:仓库收料单从原料结算详情单取
  2821 +UPDATE procurement_warehouse_receive_order t JOIN procurement_material_settle_detail s ON s.id = t.settle_detail_id
  2822 +SET t.purchase_department_id = s.purchase_department_id, t.region_id = s.region_id;
  2823 +
2791 2824
2792 2825 CREATE TABLE IF NOT EXISTS `procurement_material_settle_apply_line`
2793 2826 (
... ...
... ... @@ -71,6 +71,16 @@ public class ProcurementWarehouseReceiveOrder extends BaseEntity implements Base
71 71 private String workshopName;
72 72
73 73 /**
  74 + * 采购处ID(取自原料结算详情单)
  75 + */
  76 + private String purchaseDepartmentId;
  77 +
  78 + /**
  79 + * 区域ID(取自原料结算详情单)
  80 + */
  81 + private String regionId;
  82 +
  83 + /**
74 84 * 备注(多行文本)
75 85 */
76 86 private String remark;
... ...
... ... @@ -63,6 +63,16 @@ public class ProcurementMaterialSettleDetail extends BaseEntity implements BaseD
63 63 private String workshopName;
64 64
65 65 /**
  66 + * 采购处ID(取自过磅码单)
  67 + */
  68 + private String purchaseDepartmentId;
  69 +
  70 + /**
  71 + * 区域ID(取自过磅码单)
  72 + */
  73 + private String regionId;
  74 +
  75 + /**
66 76 * 分厂编号(联表 base_data_workshop 带出,非数据库字段;分厂审核节点编码 = material_settle_ + 分厂前缀 + 环节缩写)
67 77 */
68 78 @TableField(exist = false)
... ...
... ... @@ -49,6 +49,16 @@ public class ProcurementAssayApply extends BaseEntity implements BaseDto {
49 49 private String workshopName;
50 50
51 51 /**
  52 + * 采购处ID(取自过磅码单)
  53 + */
  54 + private String purchaseDepartmentId;
  55 +
  56 + /**
  57 + * 区域ID(取自过磅码单)
  58 + */
  59 + private String regionId;
  60 +
  61 + /**
52 62 * 分厂编码
53 63 */
54 64 @TableField(exist = false)
... ...
... ... @@ -44,6 +44,16 @@ public class ProcurementAssayReport extends BaseEntity implements BaseDto {
44 44 private String workshopName;
45 45
46 46 /**
  47 + * 采购处ID(取自过磅码单)
  48 + */
  49 + private String purchaseDepartmentId;
  50 +
  51 + /**
  52 + * 区域ID(取自过磅码单)
  53 + */
  54 + private String regionId;
  55 +
  56 + /**
47 57 * 分厂编号(联表 base_data_workshop 带出,非数据库字段)
48 58 */
49 59 @TableField(exist = false)
... ...
... ... @@ -85,6 +85,16 @@ public class ProcurementWeighingTicket extends BaseEntity implements BaseDto {
85 85 private String workshopName;
86 86
87 87 /**
  88 + * 采购处ID(关联采购计划的采购处,前端保证同一码单的计划同一采购处)
  89 + */
  90 + private String purchaseDepartmentId;
  91 +
  92 + /**
  93 + * 区域ID(关联采购计划的区域,前端保证同一码单的计划同一区域)
  94 + */
  95 + private String regionId;
  96 +
  97 + /**
88 98 * 收料单位分厂编码
89 99 */
90 100 @TableField(exist = false)
... ...
... ... @@ -349,6 +349,8 @@ public class ProcurementWarehouseReceiveOrderServiceImpl
349 349 entity.setPlanIds(settle.getPlanIds());
350 350 entity.setWorkshopId(settle.getWorkshopId());
351 351 entity.setWorkshopName(settle.getWorkshopName());
  352 + entity.setPurchaseDepartmentId(settle.getPurchaseDepartmentId());
  353 + entity.setRegionId(settle.getRegionId());
352 354 entity.setRemark(vo.getRemark());
353 355 entity.setAttachmentFileIds(vo.getAttachmentFileIds());
354 356 entity.setAttachmentFileNames(vo.getAttachmentFileNames());
... ...
... ... @@ -583,6 +583,8 @@ public class ProcurementMaterialSettleDetailServiceImpl
583 583 entity.setSupplierName(ticket.getSupplierName());
584 584 entity.setWorkshopId(ticket.getWorkshopId());
585 585 entity.setWorkshopName(ticket.getWorkshopName());
  586 + entity.setPurchaseDepartmentId(ticket.getPurchaseDepartmentId());
  587 + entity.setRegionId(ticket.getRegionId());
586 588 entity.setTotalWeighQuantity(vo.getTotalWeighQuantity());
587 589 entity.setTotalFoldWeight(vo.getTotalFoldWeight());
588 590 entity.setTotalReturnWeight(vo.getTotalReturnWeight());
... ...
... ... @@ -448,6 +448,8 @@ public class ProcurementAssayApplyServiceImpl
448 448 entity.setWeighingTicketCode(ticket.getCode());
449 449 entity.setWorkshopId(ticket.getWorkshopId());
450 450 entity.setWorkshopName(ticket.getWorkshopName());
  451 + entity.setPurchaseDepartmentId(ticket.getPurchaseDepartmentId());
  452 + entity.setRegionId(ticket.getRegionId());
451 453 entity.setProcurementPlanId(matchedPlan.getProcurementPlanId());
452 454 entity.setPlanCode(matchedPlan.getPlanCode());
453 455 entity.setProductId(matchedLine.getProductId());
... ...
... ... @@ -713,6 +713,8 @@ public class ProcurementAssayReportServiceImpl
713 713 entity.setWeighingTicketCode(ticket.getCode());
714 714 entity.setWorkshopId(ticket.getWorkshopId());
715 715 entity.setWorkshopName(ticket.getWorkshopName());
  716 + entity.setPurchaseDepartmentId(ticket.getPurchaseDepartmentId());
  717 + entity.setRegionId(ticket.getRegionId());
716 718 entity.setSupplierName(ticket.getSupplierName());
717 719 entity.setProcurementPlanId(procurementPlanId);
718 720 entity.setPlanCode(firstWeigh.getPlanCode());
... ...
... ... @@ -226,6 +226,9 @@ public class ProcurementWeighingTicketServiceImpl
226 226 entity.setCompanyShortName(first.getCompanyShortName());
227 227 entity.setWorkshopId(first.getWorkshopId());
228 228 entity.setWorkshopName(first.getWorkshopName());
  229 + // 采购处/区域取第一个计划(前端保证同一码单的计划同一采购处、区域)
  230 + entity.setPurchaseDepartmentId(first.getPurchaseDepartment());
  231 + entity.setRegionId(first.getRegion());
229 232 entity.setBuyout(isBuyout(plans));
230 233 entity.setApprovalStatus(STATUS_DRAFT);
231 234 entity.setDeleted(false);
... ... @@ -269,6 +272,8 @@ public class ProcurementWeighingTicketServiceImpl
269 272 .set(ProcurementWeighingTicket::getCompanyShortName, first.getCompanyShortName())
270 273 .set(ProcurementWeighingTicket::getWorkshopId, first.getWorkshopId())
271 274 .set(ProcurementWeighingTicket::getWorkshopName, first.getWorkshopName())
  275 + .set(ProcurementWeighingTicket::getPurchaseDepartmentId, first.getPurchaseDepartment())
  276 + .set(ProcurementWeighingTicket::getRegionId, first.getRegion())
272 277 .set(ProcurementWeighingTicket::getBuyout, isBuyout(plans))
273 278 .set(ProcurementWeighingTicket::getMaterialName, vo.getMaterialName())
274 279 .set(ProcurementWeighingTicket::getTotalGrossWeight, vo.getTotalGrossWeight())
... ...