wanghongzhi 2 тижнів тому
батько
коміт
b8621b2192

+ 13 - 2
easydo-common/src/main/java/easydo/technology/utils/ResultSetUtil.java

@@ -555,15 +555,26 @@ public class ResultSetUtil {
 
         StringBuilder stringBuffer = new StringBuilder();
         stringBuffer.append("update ").append(tableName).append(" set ");
-        Field[] declaredFields = obj.getClass().getDeclaredFields();
-        for (Field field : declaredFields) {
+        Field[] superDeclaredFields = obj.getClass().getSuperclass().getDeclaredFields();
+        for (Field field : superDeclaredFields) {
             field.setAccessible(true);
             if ("emptyField".equals(field.getName()) && StringUtil.isNotEmpty(field.get(obj))) {
                 List<String> emptyFields = (List<String>) field.get(obj);
+                if (null == emptyFields) {
+                    continue;
+                }
                 for (String fieldName : emptyFields) {
                     stringBuffer.append("`").append(humpToLine(fieldName)).append("`").append("=null,");
                 }
             }
+        }
+
+        Field[] declaredFields = obj.getClass().getDeclaredFields();
+        for (Field field : declaredFields) {
+            field.setAccessible(true);
+            if (field.isAnnotationPresent(NotTableField.class)) {
+                continue;
+            }
             if (field.isAnnotationPresent(TableField.class)) {
                 if (!field.getAnnotation(TableField.class).exist()) {
                     continue;

+ 42 - 30
easydo-core/src/main/java/easydo/technology/components/JdbcClient.java

@@ -990,59 +990,71 @@ public class JdbcClient {
 
     private void saveMinioFile(Object model, Connection connection) throws Exception {
         if (model instanceof CommonModel) {
+            CommonModel minio = (CommonModel) model;
+            boolean isMinioAnnotation = model.getClass().isAnnotationPresent(Minio.class);
+            if (!isMinioAnnotation) {
+                return;
+            }
+            String refType = model.getClass().getAnnotation(Minio.class).value();
+            if (StringUtil.isEmpty(refType)) {
+                refType = ResultSetUtil.humpToLine(model.getClass().getSimpleName());
+            }
             Field idField = model.getClass().getDeclaredField("id");
             idField.setAccessible(true);
             String refId = idField.get(model).toString();
 
-            CommonModel minio = (CommonModel) model;
-            boolean isMinioAnnotation = model.getClass().isAnnotationPresent(Minio.class);
-            String refType = model.getClass().getAnnotation(Minio.class).value();
-            if (isMinioAnnotation && StringUtil.isNotEmpty(refType)) {
-                List<MinioFile> fileList = minio.getFileList();
-                if (null == fileList) {
-                    return;
-                }
-                for (MinioFile file : fileList) {
-                    file.setRefId(refId);
-                    file.setRefType(refType);
-                    jdbcInsert(file, connection);
-                }
+            List<MinioFile> fileList = minio.getFileList();
+            if (null == fileList) {
+                return;
+            }
+            for (MinioFile file : fileList) {
+                file.setRefId(refId);
+                file.setRefType(refType);
+                jdbcInsert(file, connection);
             }
         }
     }
 
     private void removeMinioFile(Object model, Connection connection) throws Exception {
         if (model instanceof CommonModel) {
+            boolean isMinioAnnotation = model.getClass().isAnnotationPresent(Minio.class);
+            if (!isMinioAnnotation) {
+                return;
+            }
+            String refType = model.getClass().getAnnotation(Minio.class).value();
+            if (StringUtil.isEmpty(refType)) {
+                refType = ResultSetUtil.humpToLine(model.getClass().getSimpleName());
+            }
             Field idField = model.getClass().getDeclaredField("id");
             idField.setAccessible(true);
             String refId = idField.get(model).toString();
 
-            boolean isMinioAnnotation = model.getClass().isAnnotationPresent(Minio.class);
-            String refType = model.getClass().getAnnotation(Minio.class).value();
-            if (isMinioAnnotation && StringUtil.isNotEmpty(refType)) {
-                MinioFile minioFile = new MinioFile();
-                minioFile.setRefId(refId);
-                minioFile.setRefType(refType);
-                jdbcRemove(minioFile, connection);
-            }
+            MinioFile minioFile = new MinioFile();
+            minioFile.setRefId(refId);
+            minioFile.setRefType(refType);
+            jdbcRemove(minioFile, connection);
         }
     }
 
     public void getMinioFile(Object model, Connection connection) throws Exception {
         if (model instanceof CommonModel) {
+            boolean isMinioAnnotation = model.getClass().isAnnotationPresent(Minio.class);
+            if (!isMinioAnnotation) {
+                return;
+            }
+            String refType = model.getClass().getAnnotation(Minio.class).value();
+            if (StringUtil.isEmpty(refType)) {
+                refType = ResultSetUtil.humpToLine(model.getClass().getSimpleName());
+            }
             Field idField = model.getClass().getDeclaredField("id");
             idField.setAccessible(true);
             String refId = idField.get(model).toString();
 
-            boolean isMinioAnnotation = model.getClass().isAnnotationPresent(Minio.class);
-            String refType = model.getClass().getAnnotation(Minio.class).value();
-            if (isMinioAnnotation && StringUtil.isNotEmpty(refType)) {
-                MinioFile minioFile = new MinioFile();
-                minioFile.setRefId(refId);
-                minioFile.setRefType(refType);
-                List<MinioFile> fileList = getJdbcList(minioFile, connection);
-                ((CommonModel) model).setFileList(fileList);
-            }
+            MinioFile minioFile = new MinioFile();
+            minioFile.setRefId(refId);
+            minioFile.setRefType(refType);
+            List<MinioFile> fileList = getJdbcList(minioFile, connection);
+            ((CommonModel) model).setFileList(fileList);
         }
     }
 }

+ 87 - 10
easydo-mes/src/main/java/easydo/technology/controller/ProcessRouteController.java

@@ -4,7 +4,7 @@ import easydo.technology.components.JdbcClient;
 import easydo.technology.enums.MESEnum;
 import easydo.technology.exception.BizException;
 import easydo.technology.model.ProcessRoute;
-import easydo.technology.model.ProcessRouteRef;
+import easydo.technology.model.ProcessRouteDetail;
 import easydo.technology.service.FlowNoService;
 import easydo.technology.utils.SecurityUtils;
 import easydo.technology.utils.StringUtil;
@@ -19,6 +19,7 @@ import javax.sql.DataSource;
 import java.sql.Connection;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 @RestController
 @RequestMapping("/processRoute")
@@ -43,10 +44,10 @@ public class ProcessRouteController {
             Map<String, Object> recordsPage = jdbcClient.getJdbcPage(map, ProcessRoute.class, connection);
             List<ProcessRoute> records = (List<ProcessRoute>) recordsPage.get("records");
             for (ProcessRoute model : records) {
-                ProcessRouteRef routeRef = new ProcessRouteRef();
-                routeRef.setRouteId(model.getId());
-                List<ProcessRouteRef> routeRefList = jdbcClient.getJdbcList(routeRef, connection);
-                model.setRefList(routeRefList);
+                ProcessRouteDetail routeDetail = new ProcessRouteDetail();
+                routeDetail.setRouteId(model.getId());
+                List<ProcessRouteDetail> routeDetailList = jdbcClient.getJdbcList(routeDetail, connection);
+                model.setDetailList(routeDetailList);
 
                 jdbcClient.getMinioFile(model, connection);
             }
@@ -60,7 +61,7 @@ public class ProcessRouteController {
 
 
     @RequestMapping(value = "/save")
-    public Object add(@RequestBody ProcessRoute model) throws Exception {
+    public Object save(@RequestBody ProcessRoute model) throws Exception {
         Connection connection = dataSource.getConnection();
         try {
             connection.setAutoCommit(false);
@@ -68,12 +69,88 @@ public class ProcessRouteController {
             if (StringUtil.isEmpty(model.getCode())) {
                 model.setCode(flowNoService.getFlowNo(MESEnum.FLOW_NO_TYPE_PROCESS_ROUTE.getValue(), connection));
             }
+            model.setStatus(MESEnum.PROCESS_ROUTE_OF_STATUS_ENABLE.getValue());
             jdbcClient.jdbcInsert(model, connection);
 
-            List<ProcessRouteRef> refList = model.getRefList();
-            for (ProcessRouteRef ref : refList) {
-                ref.setRouteId(model.getId());
-                jdbcClient.jdbcInsert(ref, connection);
+            List<ProcessRouteDetail> detailList = model.getDetailList();
+            for (ProcessRouteDetail detail : detailList) {
+                detail.setRouteId(model.getId());
+                jdbcClient.jdbcInsert(detail, connection);
+            }
+            connection.commit();
+            return new ResponseEntity<>(model, HttpStatus.OK);
+        } catch (Exception e) {
+            connection.rollback();
+            throw new BizException(e.getMessage());
+        } finally {
+            connection.close();
+        }
+    }
+
+    @RequestMapping(value = "/update")
+    public Object update(@RequestBody ProcessRoute model) throws Exception {
+        Connection connection = dataSource.getConnection();
+        try {
+            connection.setAutoCommit(false);
+            jdbcClient.jdbcUpdateById(model, connection);
+
+            ProcessRouteDetail routeDetail = new ProcessRouteDetail();
+            routeDetail.setRouteId(model.getId());
+            jdbcClient.jdbcRemove(routeDetail, connection);
+
+            List<ProcessRouteDetail> detailList = model.getDetailList();
+            for (ProcessRouteDetail detail : detailList) {
+                detail.setRouteId(model.getId());
+                jdbcClient.jdbcInsert(detail, connection);
+            }
+            connection.commit();
+            return new ResponseEntity<>(model, HttpStatus.OK);
+        } catch (Exception e) {
+            connection.rollback();
+            throw new BizException(e.getMessage());
+        } finally {
+            connection.close();
+        }
+    }
+
+    @RequestMapping(value = "/remove")
+    public Object remove(@RequestBody ProcessRoute model) throws Exception {
+        Connection connection = dataSource.getConnection();
+        try {
+            connection.setAutoCommit(false);
+            jdbcClient.jdbcRemoveById(model, connection);
+
+            ProcessRouteDetail routeDetail = new ProcessRouteDetail();
+            routeDetail.setRouteId(model.getId());
+            jdbcClient.jdbcRemove(routeDetail, connection);
+
+            connection.commit();
+            return new ResponseEntity<>(model, HttpStatus.OK);
+        } catch (Exception e) {
+            connection.rollback();
+            throw new BizException(e.getMessage());
+        } finally {
+            connection.close();
+        }
+    }
+
+    @RequestMapping(value = "/upgrade")
+    public Object upgrade(@RequestBody ProcessRoute model) throws Exception {
+        Connection connection = dataSource.getConnection();
+        try {
+            connection.setAutoCommit(false);
+            model.setCreateId(SecurityUtils.getCurrentUserId());
+            if (StringUtil.isEmpty(model.getCode())) {
+                model.setCode(flowNoService.getFlowNo(MESEnum.FLOW_NO_TYPE_PROCESS_ROUTE.getValue(), connection));
+            }
+            model.setParentId(model.getId());
+            model.setId(UUID.randomUUID().toString());
+            jdbcClient.jdbcInsert(model, connection);
+
+            List<ProcessRouteDetail> detailList = model.getDetailList();
+            for (ProcessRouteDetail detail : detailList) {
+                detail.setRouteId(model.getId());
+                jdbcClient.jdbcInsert(detail, connection);
             }
             connection.commit();
             return new ResponseEntity<>(model, HttpStatus.OK);

+ 1 - 0
easydo-mes/src/main/java/easydo/technology/controller/ProcessStageController.java

@@ -87,4 +87,5 @@ public class ProcessStageController {
         return new ResponseEntity<>(HttpStatus.OK);
     }
 
+
 }

+ 2 - 0
easydo-mes/src/main/java/easydo/technology/enums/MESEnum.java

@@ -24,6 +24,8 @@ public enum MESEnum {
     PROCESS_STAGE_OF_STATUS_ENABLE("enable","启用"),
     PROCESS_STAGE_OF_STATUS_DISABLE("disable","停用"),
 
+    PROCESS_ROUTE_OF_STATUS_ENABLE("enable", "启用"),
+    PROCESS_ROUTE_OF_STATUS_DISABLE("disable", "停用"),
     ;
 
     MESEnum(String value, String comment) {

+ 4 - 2
easydo-mes/src/main/java/easydo/technology/model/ProcessRoute.java

@@ -8,17 +8,19 @@ import lombok.EqualsAndHashCode;
 import java.util.List;
 
 @Data
-@Minio("processRoute")
+@Minio
 @EqualsAndHashCode(callSuper = true)
 public class ProcessRoute extends CommonModel {
     private String id;
     private String name;
+    private String parentId;
     private String code;
     private String timeUnit;
     private String createTime;
     private Long createId;
+    private String status;
     private String remark;
 
     @NotTableField
-    private List<ProcessRouteRef> refList;
+    private List<ProcessRouteDetail> detailList;
 }

+ 8 - 4
easydo-mes/src/main/java/easydo/technology/model/ProcessRouteRef.java

@@ -1,20 +1,24 @@
 package easydo.technology.model;
 
+import easydo.technology.annotation.Minio;
 import lombok.Data;
 
 import java.math.BigDecimal;
 
 @Data
-public class ProcessRouteRef {
+@Minio
+public class ProcessRouteDetail {
     private String id;
     private String routeId;
     private String stageId;
     private Integer orderNum;
     private BigDecimal readyTimeHour;
-    private Integer processNum;
+    private BigDecimal processNum;
     private BigDecimal processTimeHour;
-    private Integer moveNum;
+    private BigDecimal moveNum;
     private BigDecimal moveTimeHour;
+    private Boolean isReview;
+    private Boolean isReport;
+    private Boolean isRound;
     private String remark;
-
 }

+ 2 - 2
easydo-mes/src/main/java/easydo/technology/model/ProcessStage.java

@@ -6,7 +6,8 @@ import lombok.EqualsAndHashCode;
 
 
 @Data
-@Minio("processManage")
+@Minio
+@EqualsAndHashCode(callSuper = true)
 public class ProcessStage extends CommonModel {
     private String id;
     private String name;
@@ -16,7 +17,6 @@ public class ProcessStage extends CommonModel {
     private String processType;
     private String category;
     private String calculateMethod;
-    private String version;
     private String remark;
     private String createTime;
     private Long createId;