Explorar el Código

fix:生产计划

lumaojun hace 1 mes
padre
commit
6e57f654d2

+ 27 - 0
easydo-mes/src/main/java/easydo/technology/controller/ProductPlanController.java

@@ -0,0 +1,27 @@
+package easydo.technology.controller;
+
+import easydo.technology.model.ProductPlan;
+import easydo.technology.service.ProductPlanService;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/productPlan")
+public class ProductPlanController {
+
+    @Resource
+    private ProductPlanService productPlanService;
+
+    @RequestMapping(value = "/getPage")
+    public Object getPage(@RequestBody Map<String, Object> map) throws Exception {
+        Map<String, Object> result = productPlanService.getPage(map);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+}
+

+ 35 - 0
easydo-mes/src/main/java/easydo/technology/model/ProductPlan.java

@@ -0,0 +1,35 @@
+package easydo.technology.model;
+
+import easydo.technology.annotation.NotTableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProductPlan extends CommonModel {
+    private String id;
+    private String name;
+    private String code;
+    private String saleOrderId;
+    private String beginDate;
+    private String endDate;
+    private String remark;
+    private String createTime;
+    private Long createId;
+    private String status;
+    private String tenantId;
+    private Long updateId;
+    private String updateTime;
+
+    @NotTableField
+    private SaleOrder saleOrder;
+    @NotTableField
+    private List<ProductPlanBom> bomList;
+    @NotTableField
+    private List<ProductPlanDevice> deviceList;
+    @NotTableField
+    private List<ProductPlanUser> userList;
+}
+

+ 27 - 0
easydo-mes/src/main/java/easydo/technology/model/ProductPlanBom.java

@@ -0,0 +1,27 @@
+package easydo.technology.model;
+
+import easydo.technology.annotation.NotTableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProductPlanBom extends CommonModel {
+    private String id;
+    private String planId;
+    private String bomId;
+    private String routeId;
+    private Double number;
+    private String createTime;
+    private String inspectProgramId;
+
+    @NotTableField
+    private ProductPlan productPlan;
+    @NotTableField
+    private ProductBom productBom;
+    @NotTableField
+    private ProcessRoute processRoute;
+    @NotTableField
+    private QualityInspectProgram inspectProgram;
+}
+

+ 20 - 0
easydo-mes/src/main/java/easydo/technology/model/ProductPlanDevice.java

@@ -0,0 +1,20 @@
+package easydo.technology.model;
+
+import easydo.technology.annotation.NotTableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProductPlanDevice extends CommonModel {
+    private String id;
+    private String planId;
+    private String deviceId;
+    private String createTime;
+
+    @NotTableField
+    private ProductPlan productPlan;
+    @NotTableField
+    private Device device;
+}
+

+ 24 - 0
easydo-mes/src/main/java/easydo/technology/model/ProductPlanUser.java

@@ -0,0 +1,24 @@
+package easydo.technology.model;
+
+import easydo.technology.annotation.NotTableField;
+import easydo.technology.system.model.SysUser;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProductPlanUser extends CommonModel {
+    private String id;
+    private String planId;
+    private String beginTime;
+    private String endTime;
+    private String routeId;
+    private String stageId;
+    private Long userId;
+
+    @NotTableField
+    private ProductPlan productPlan;
+    @NotTableField
+    private SysUser user;
+}
+

+ 8 - 0
easydo-mes/src/main/java/easydo/technology/service/ProductPlanService.java

@@ -0,0 +1,8 @@
+package easydo.technology.service;
+
+import java.util.Map;
+
+public interface ProductPlanService {
+    Map<String, Object> getPage(Map<String, Object> map) throws Exception;
+}
+

+ 122 - 0
easydo-mes/src/main/java/easydo/technology/service/impl/ProductPlanServiceImpl.java

@@ -0,0 +1,122 @@
+package easydo.technology.service.impl;
+
+import easydo.technology.components.JdbcClient;
+import easydo.technology.exception.BizException;
+import easydo.technology.model.*;
+import easydo.technology.service.ProductPlanService;
+import easydo.technology.system.model.SysUser;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class ProductPlanServiceImpl implements ProductPlanService {
+
+    @Resource
+    private JdbcClient jdbcClient;
+    @Resource
+    private DataSource dataSource;
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map<String, Object> getPage(Map<String, Object> map) throws Exception {
+        Connection connection = dataSource.getConnection();
+        try {
+            Map<String, Object> result = jdbcClient.getJdbcPage(map, ProductPlan.class, connection);
+            List<ProductPlan> list = (List<ProductPlan>) result.get("records");
+            if (list == null || list.isEmpty()) {
+                return result;
+            }
+
+            for (ProductPlan model : list) {
+                jdbcClient.getMinioFile(model, connection);
+
+                if (model.getSaleOrderId() != null) {
+                    SaleOrder saleOrderParam = new SaleOrder();
+                    saleOrderParam.setId(model.getSaleOrderId());
+                    SaleOrder saleOrder = jdbcClient.getJdbcModelById(saleOrderParam, connection);
+                    if (saleOrder != null) {
+                        jdbcClient.getMinioFile(saleOrder, connection);
+
+                        SaleOrderDetail detailParam = new SaleOrderDetail();
+                        detailParam.setOrderId(saleOrder.getId());
+                        List<SaleOrderDetail> detailList = jdbcClient.getJdbcList(detailParam, connection);
+                        if (detailList != null) {
+                            for (SaleOrderDetail detail : detailList) {
+                                ProductMaterial materialParam = new ProductMaterial();
+                                materialParam.setCode(detail.getMaterialCode());
+                                ProductMaterial material = jdbcClient.getJdbcModel(materialParam, connection);
+                                detail.setMaterial(material);
+                            }
+                        }
+                        saleOrder.setChildrenList(detailList);
+                        model.setSaleOrder(saleOrder);
+                    }
+                }
+
+                ProductPlanBom bomParam = new ProductPlanBom();
+                bomParam.setPlanId(model.getId());
+                List<ProductPlanBom> bomList = jdbcClient.getJdbcList(bomParam, connection);
+                if (bomList != null) {
+                    for (ProductPlanBom planBom : bomList) {
+                        if (planBom.getRouteId() != null) {
+                            ProcessRoute routeParam = new ProcessRoute();
+                            routeParam.setId(planBom.getRouteId());
+                            planBom.setProcessRoute(jdbcClient.getJdbcModelById(routeParam, connection));
+                        }
+                        if (planBom.getInspectProgramId() != null) {
+                            QualityInspectProgram programParam = new QualityInspectProgram();
+                            programParam.setId(planBom.getInspectProgramId());
+                            planBom.setInspectProgram(jdbcClient.getJdbcModelById(programParam, connection));
+                        }
+                        if (planBom.getBomId() != null) {
+                            ProductBom productBomParam = new ProductBom();
+                            productBomParam.setId(planBom.getBomId());
+                            planBom.setProductBom(jdbcClient.getJdbcModelById(productBomParam, connection));
+                        }
+                    }
+                }
+                model.setBomList(bomList);
+
+                ProductPlanDevice deviceParam = new ProductPlanDevice();
+                deviceParam.setPlanId(model.getId());
+                List<ProductPlanDevice> deviceList = jdbcClient.getJdbcList(deviceParam, connection);
+                if (deviceList != null) {
+                    for (ProductPlanDevice planDevice : deviceList) {
+                        if (planDevice.getDeviceId() != null) {
+                            Device deviceModel = new Device();
+                            deviceModel.setId(planDevice.getDeviceId());
+                            planDevice.setDevice(jdbcClient.getJdbcModelById(deviceModel, connection));
+                        }
+                    }
+                }
+                model.setDeviceList(deviceList);
+
+                ProductPlanUser userParam = new ProductPlanUser();
+                userParam.setPlanId(model.getId());
+                List<ProductPlanUser> userList = jdbcClient.getJdbcList(userParam, connection);
+                if (userList != null) {
+                    for (ProductPlanUser planUser : userList) {
+                        if (planUser.getUserId() != null) {
+                            SysUser userModel = new SysUser();
+                            userModel.setId(planUser.getUserId());
+                            planUser.setUser(jdbcClient.getJdbcModelById(userModel, connection));
+                        }
+                    }
+                }
+                model.setUserList(userList);
+            }
+
+            return result;
+        } catch (Exception e) {
+            throw new BizException(e.getMessage());
+        } finally {
+            connection.close();
+        }
+    }
+}
+