瀏覽代碼

fix:委外

lumaojun 2 周之前
父節點
當前提交
e09704d817

+ 15 - 0
easydo-mes/src/main/java/easydo/technology/controller/OutsourcingPlanController.java

@@ -2,6 +2,7 @@ package easydo.technology.controller;
 
 import easydo.technology.model.OutsourcingPlan;
 import easydo.technology.service.OutsourcingPlanService;
+import easydo.technology.utils.SecurityUtils;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -26,11 +27,25 @@ public class OutsourcingPlanController {
 
     @RequestMapping(value = "/save")
     public Object save(@RequestBody OutsourcingPlan model) throws Exception {
+        // 校验用户登录状态
+        Long userId = SecurityUtils.getCurrentUserId();
+        if (userId == null) {
+            return new ResponseEntity<>("用户请先登录", HttpStatus.UNAUTHORIZED);
+        }
+
+        model.setCreateId(userId);
         return new ResponseEntity<>(outsourcingPlanService.save(model), HttpStatus.OK);
     }
 
     @RequestMapping(value = "/update")
     public Object update(@RequestBody OutsourcingPlan model) throws Exception {
+        // 校验用户登录状态
+        Long userId = SecurityUtils.getCurrentUserId();
+        if (userId == null) {
+            return new ResponseEntity<>("用户请先登录", HttpStatus.UNAUTHORIZED);
+        }
+
+        model.setUpdateId(userId);
         return new ResponseEntity<>(outsourcingPlanService.update(model), HttpStatus.OK);
     }
 

+ 1 - 0
easydo-mes/src/main/java/easydo/technology/model/OutsourcingPlan.java

@@ -25,6 +25,7 @@ public class OutsourcingPlan extends CommonModel {
     private String endDate;
     private String type;
     private String priority;
+    private String remark;
 
     // 非数据库字段
     @NotTableField

+ 49 - 7
easydo-mes/src/main/java/easydo/technology/service/impl/OutsourcingPlanServiceImpl.java

@@ -2,12 +2,11 @@ package easydo.technology.service.impl;
 
 import easydo.technology.components.JdbcClient;
 import easydo.technology.exception.BizException;
-import easydo.technology.model.OutsourcingPlan;
-import easydo.technology.model.OutsourcingPlanDetail;
-import easydo.technology.model.ProductMaterial;
-import easydo.technology.model.SaleOrder;
+import easydo.technology.model.*;
 import easydo.technology.service.FlowNoService;
 import easydo.technology.service.OutsourcingPlanService;
+import easydo.technology.system.model.SysUser;
+import easydo.technology.utils.StringUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -48,13 +47,56 @@ public class OutsourcingPlanServiceImpl implements OutsourcingPlanService {
                 // 2. 补全文件列表 (JdbcClient 会根据 @Minio 注解自动处理)
                 try {
                     jdbcClient.getMinioFile(model, connection);
-                } catch (Exception e) {}
+                } catch (Exception e) {
+                    // 打印错误但继续执行
+                }
 
-                // 3. 补全销售订单信息
+                // 3. 补全销售订单 SaleOrder 及其明细
                 if (model.getSaleOrderId() != null) {
                     SaleOrder saleOrderParam = new SaleOrder();
                     saleOrderParam.setId(model.getSaleOrderId());
-                    model.setSaleOrder(jdbcClient.getJdbcModelById(saleOrderParam, connection));
+                    SaleOrder saleOrder = jdbcClient.getJdbcModelById(saleOrderParam, connection);
+
+                    if (saleOrder != null) {
+                        // 3.1 获取销售订单明细列表
+                        SaleOrderDetail saleOrderDetailParam = new SaleOrderDetail();
+                        saleOrderDetailParam.setOrderId(saleOrder.getId());
+                        List<SaleOrderDetail> saleOrderDetailList = jdbcClient.getJdbcList(saleOrderDetailParam, connection);
+
+                        if (saleOrderDetailList != null) {
+                            for (SaleOrderDetail detail : saleOrderDetailList) {
+                                // 3.2 补全销售订单明细中的物料信息
+                                if (detail.getMaterialCode() != null) {
+                                    ProductMaterial materialParam = new ProductMaterial();
+                                    materialParam.setCode(detail.getMaterialCode());
+                                    detail.setMaterial(jdbcClient.getJdbcModel(materialParam, connection));
+                                }
+                            }
+                            saleOrder.setChildrenList(saleOrderDetailList);
+                        }
+
+                        // 3.3 补全销售订单的负责人姓名 ManagerName
+                        if (StringUtil.isNotEmpty(saleOrder.getManagerId())) {
+                            SysUser managerParam = new SysUser();
+                            managerParam.setId(saleOrder.getManagerId());
+                            SysUser manager = jdbcClient.getJdbcModelById(managerParam, connection);
+                            if (manager != null) {
+                                saleOrder.setManagerName(manager.getNickName());
+                            }
+                        }
+
+                        // 3.4 补全销售订单的客户名称 CustomerName
+                        if (StringUtil.isNotEmpty(saleOrder.getCustomerId())) {
+                            Customer customerParam = new Customer();
+                            customerParam.setId(saleOrder.getCustomerId());
+                            Customer customer = jdbcClient.getJdbcModelById(customerParam, connection);
+                            if (customer != null) {
+                                saleOrder.setCustomerName(customer.getName());
+                            }
+                        }
+
+                        model.setSaleOrder(saleOrder);
+                    }
                 }
 
                 // 4. 补全明细列表及物料信息