|
@@ -24,8 +24,11 @@ public class ProductPlanServiceImpl implements ProductPlanService {
|
|
|
@Override
|
|
@Override
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
|
public Map<String, Object> getPage(Map<String, Object> map) throws Exception {
|
|
public Map<String, Object> getPage(Map<String, Object> map) throws Exception {
|
|
|
|
|
+ // 说明:该接口按 Go 版本的实现方式进行 1:1 同步,采用“分页查询 + 循环逐条补齐关联数据”的方式组装返回结果。
|
|
|
|
|
+ // 注意:这种写法会产生较多的数据库访问(N+1 查询),但可以确保前端一次请求拿到完整的数据树结构。
|
|
|
Connection connection = dataSource.getConnection();
|
|
Connection connection = dataSource.getConnection();
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 1) 查询生产计划分页数据(基础字段来自 product_plan 表)
|
|
|
Map<String, Object> result = jdbcClient.getJdbcPage(map, ProductPlan.class, connection);
|
|
Map<String, Object> result = jdbcClient.getJdbcPage(map, ProductPlan.class, connection);
|
|
|
List<ProductPlan> list = (List<ProductPlan>) result.get("records");
|
|
List<ProductPlan> list = (List<ProductPlan>) result.get("records");
|
|
|
if (list == null || list.isEmpty()) {
|
|
if (list == null || list.isEmpty()) {
|
|
@@ -33,46 +36,57 @@ public class ProductPlanServiceImpl implements ProductPlanService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (ProductPlan model : list) {
|
|
for (ProductPlan model : list) {
|
|
|
|
|
+ // 2) 查询并回填生产计划的附件(Minio 文件列表)
|
|
|
jdbcClient.getMinioFile(model, connection);
|
|
jdbcClient.getMinioFile(model, connection);
|
|
|
|
|
|
|
|
|
|
+ // 3) 查询并回填关联销售订单(SaleOrder)及其附件、明细、明细物料信息
|
|
|
if (model.getSaleOrderId() != null) {
|
|
if (model.getSaleOrderId() != null) {
|
|
|
|
|
+ // 3.1) 按 saleOrderId 查询销售订单主表
|
|
|
SaleOrder saleOrderParam = new SaleOrder();
|
|
SaleOrder saleOrderParam = new SaleOrder();
|
|
|
saleOrderParam.setId(model.getSaleOrderId());
|
|
saleOrderParam.setId(model.getSaleOrderId());
|
|
|
SaleOrder saleOrder = jdbcClient.getJdbcModelById(saleOrderParam, connection);
|
|
SaleOrder saleOrder = jdbcClient.getJdbcModelById(saleOrderParam, connection);
|
|
|
if (saleOrder != null) {
|
|
if (saleOrder != null) {
|
|
|
|
|
+ // 3.2) 查询并回填销售订单附件
|
|
|
jdbcClient.getMinioFile(saleOrder, connection);
|
|
jdbcClient.getMinioFile(saleOrder, connection);
|
|
|
|
|
|
|
|
|
|
+ // 3.3) 查询销售订单明细(SaleOrderDetail 列表)
|
|
|
SaleOrderDetail detailParam = new SaleOrderDetail();
|
|
SaleOrderDetail detailParam = new SaleOrderDetail();
|
|
|
detailParam.setOrderId(saleOrder.getId());
|
|
detailParam.setOrderId(saleOrder.getId());
|
|
|
List<SaleOrderDetail> detailList = jdbcClient.getJdbcList(detailParam, connection);
|
|
List<SaleOrderDetail> detailList = jdbcClient.getJdbcList(detailParam, connection);
|
|
|
if (detailList != null) {
|
|
if (detailList != null) {
|
|
|
for (SaleOrderDetail detail : detailList) {
|
|
for (SaleOrderDetail detail : detailList) {
|
|
|
|
|
+ // 3.4) 对每条明细查询物料信息(ProductMaterial)并回填到 detail.material
|
|
|
ProductMaterial materialParam = new ProductMaterial();
|
|
ProductMaterial materialParam = new ProductMaterial();
|
|
|
materialParam.setCode(detail.getMaterialCode());
|
|
materialParam.setCode(detail.getMaterialCode());
|
|
|
ProductMaterial material = jdbcClient.getJdbcModel(materialParam, connection);
|
|
ProductMaterial material = jdbcClient.getJdbcModel(materialParam, connection);
|
|
|
detail.setMaterial(material);
|
|
detail.setMaterial(material);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 3.5) 将明细列表回填到 saleOrder.childrenList,并将 saleOrder 回填到 plan.saleOrder
|
|
|
saleOrder.setChildrenList(detailList);
|
|
saleOrder.setChildrenList(detailList);
|
|
|
model.setSaleOrder(saleOrder);
|
|
model.setSaleOrder(saleOrder);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 4) 查询并回填计划 BOM 列表(ProductPlanBom),并补齐其关联:工艺路线/质检方案/产品BOM
|
|
|
ProductPlanBom bomParam = new ProductPlanBom();
|
|
ProductPlanBom bomParam = new ProductPlanBom();
|
|
|
bomParam.setPlanId(model.getId());
|
|
bomParam.setPlanId(model.getId());
|
|
|
List<ProductPlanBom> bomList = jdbcClient.getJdbcList(bomParam, connection);
|
|
List<ProductPlanBom> bomList = jdbcClient.getJdbcList(bomParam, connection);
|
|
|
if (bomList != null) {
|
|
if (bomList != null) {
|
|
|
for (ProductPlanBom planBom : bomList) {
|
|
for (ProductPlanBom planBom : bomList) {
|
|
|
|
|
+ // 4.1) 工艺路线(ProcessRoute)
|
|
|
if (planBom.getRouteId() != null) {
|
|
if (planBom.getRouteId() != null) {
|
|
|
ProcessRoute routeParam = new ProcessRoute();
|
|
ProcessRoute routeParam = new ProcessRoute();
|
|
|
routeParam.setId(planBom.getRouteId());
|
|
routeParam.setId(planBom.getRouteId());
|
|
|
planBom.setProcessRoute(jdbcClient.getJdbcModelById(routeParam, connection));
|
|
planBom.setProcessRoute(jdbcClient.getJdbcModelById(routeParam, connection));
|
|
|
}
|
|
}
|
|
|
|
|
+ // 4.2) 质检方案(QualityInspectProgram)
|
|
|
if (planBom.getInspectProgramId() != null) {
|
|
if (planBom.getInspectProgramId() != null) {
|
|
|
QualityInspectProgram programParam = new QualityInspectProgram();
|
|
QualityInspectProgram programParam = new QualityInspectProgram();
|
|
|
programParam.setId(planBom.getInspectProgramId());
|
|
programParam.setId(planBom.getInspectProgramId());
|
|
|
planBom.setInspectProgram(jdbcClient.getJdbcModelById(programParam, connection));
|
|
planBom.setInspectProgram(jdbcClient.getJdbcModelById(programParam, connection));
|
|
|
}
|
|
}
|
|
|
|
|
+ // 4.3) 产品 BOM(ProductBom)
|
|
|
if (planBom.getBomId() != null) {
|
|
if (planBom.getBomId() != null) {
|
|
|
ProductBom productBomParam = new ProductBom();
|
|
ProductBom productBomParam = new ProductBom();
|
|
|
productBomParam.setId(planBom.getBomId());
|
|
productBomParam.setId(planBom.getBomId());
|
|
@@ -82,6 +96,7 @@ public class ProductPlanServiceImpl implements ProductPlanService {
|
|
|
}
|
|
}
|
|
|
model.setBomList(bomList);
|
|
model.setBomList(bomList);
|
|
|
|
|
|
|
|
|
|
+ // 5) 查询并回填计划设备列表(ProductPlanDevice),并补齐设备基础信息(Device)
|
|
|
ProductPlanDevice deviceParam = new ProductPlanDevice();
|
|
ProductPlanDevice deviceParam = new ProductPlanDevice();
|
|
|
deviceParam.setPlanId(model.getId());
|
|
deviceParam.setPlanId(model.getId());
|
|
|
List<ProductPlanDevice> deviceList = jdbcClient.getJdbcList(deviceParam, connection);
|
|
List<ProductPlanDevice> deviceList = jdbcClient.getJdbcList(deviceParam, connection);
|
|
@@ -96,6 +111,7 @@ public class ProductPlanServiceImpl implements ProductPlanService {
|
|
|
}
|
|
}
|
|
|
model.setDeviceList(deviceList);
|
|
model.setDeviceList(deviceList);
|
|
|
|
|
|
|
|
|
|
+ // 6) 查询并回填计划人员列表(ProductPlanUser),并补齐人员信息(SysUser)
|
|
|
ProductPlanUser userParam = new ProductPlanUser();
|
|
ProductPlanUser userParam = new ProductPlanUser();
|
|
|
userParam.setPlanId(model.getId());
|
|
userParam.setPlanId(model.getId());
|
|
|
List<ProductPlanUser> userList = jdbcClient.getJdbcList(userParam, connection);
|
|
List<ProductPlanUser> userList = jdbcClient.getJdbcList(userParam, connection);
|