|
@@ -5,6 +5,7 @@ import easydo.technology.enums.MESEnum;
|
|
|
import easydo.technology.exception.BizException;
|
|
import easydo.technology.exception.BizException;
|
|
|
import easydo.technology.model.ProcessRoute;
|
|
import easydo.technology.model.ProcessRoute;
|
|
|
import easydo.technology.model.ProcessRouteDetail;
|
|
import easydo.technology.model.ProcessRouteDetail;
|
|
|
|
|
+import easydo.technology.model.ProcessStage;
|
|
|
import easydo.technology.service.FlowNoService;
|
|
import easydo.technology.service.FlowNoService;
|
|
|
import easydo.technology.utils.SecurityUtils;
|
|
import easydo.technology.utils.SecurityUtils;
|
|
|
import easydo.technology.utils.StringUtil;
|
|
import easydo.technology.utils.StringUtil;
|
|
@@ -17,9 +18,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.sql.DataSource;
|
|
import javax.sql.DataSource;
|
|
|
import java.sql.Connection;
|
|
import java.sql.Connection;
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/processRoute")
|
|
@RequestMapping("/processRoute")
|
|
@@ -47,9 +47,24 @@ public class ProcessRouteController {
|
|
|
ProcessRouteDetail routeDetail = new ProcessRouteDetail();
|
|
ProcessRouteDetail routeDetail = new ProcessRouteDetail();
|
|
|
routeDetail.setRouteId(model.getId());
|
|
routeDetail.setRouteId(model.getId());
|
|
|
List<ProcessRouteDetail> routeDetailList = jdbcClient.getJdbcList(routeDetail, connection);
|
|
List<ProcessRouteDetail> routeDetailList = jdbcClient.getJdbcList(routeDetail, connection);
|
|
|
|
|
+ for (ProcessRouteDetail detail : routeDetailList) {
|
|
|
|
|
+ ProcessStage stage = new ProcessStage();
|
|
|
|
|
+ stage.setId(detail.getStageId());
|
|
|
|
|
+ stage = jdbcClient.getJdbcModelById(stage, connection);
|
|
|
|
|
+ detail.setStage(stage);
|
|
|
|
|
+ }
|
|
|
model.setDetailList(routeDetailList);
|
|
model.setDetailList(routeDetailList);
|
|
|
|
|
|
|
|
jdbcClient.getMinioFile(model, connection);
|
|
jdbcClient.getMinioFile(model, connection);
|
|
|
|
|
+
|
|
|
|
|
+ ProcessRoute child = new ProcessRoute();
|
|
|
|
|
+ child.setParentId(model.getId());
|
|
|
|
|
+ int count = jdbcClient.getJdbcCount(child, connection);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ model.setIsHaveHistory(true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ model.setIsHaveHistory(false);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return new ResponseEntity<>(recordsPage, HttpStatus.OK);
|
|
return new ResponseEntity<>(recordsPage, HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -69,6 +84,7 @@ public class ProcessRouteController {
|
|
|
if (StringUtil.isEmpty(model.getCode())) {
|
|
if (StringUtil.isEmpty(model.getCode())) {
|
|
|
model.setCode(flowNoService.getFlowNo(MESEnum.FLOW_NO_TYPE_PROCESS_ROUTE.getValue(), connection));
|
|
model.setCode(flowNoService.getFlowNo(MESEnum.FLOW_NO_TYPE_PROCESS_ROUTE.getValue(), connection));
|
|
|
}
|
|
}
|
|
|
|
|
+ model.setParentId("0");
|
|
|
model.setStatus(MESEnum.PROCESS_ROUTE_OF_STATUS_ENABLE.getValue());
|
|
model.setStatus(MESEnum.PROCESS_ROUTE_OF_STATUS_ENABLE.getValue());
|
|
|
jdbcClient.jdbcInsert(model, connection);
|
|
jdbcClient.jdbcInsert(model, connection);
|
|
|
|
|
|
|
@@ -94,14 +110,16 @@ public class ProcessRouteController {
|
|
|
connection.setAutoCommit(false);
|
|
connection.setAutoCommit(false);
|
|
|
jdbcClient.jdbcUpdateById(model, connection);
|
|
jdbcClient.jdbcUpdateById(model, connection);
|
|
|
|
|
|
|
|
- ProcessRouteDetail routeDetail = new ProcessRouteDetail();
|
|
|
|
|
- routeDetail.setRouteId(model.getId());
|
|
|
|
|
- jdbcClient.jdbcRemove(routeDetail, connection);
|
|
|
|
|
-
|
|
|
|
|
List<ProcessRouteDetail> detailList = model.getDetailList();
|
|
List<ProcessRouteDetail> detailList = model.getDetailList();
|
|
|
- for (ProcessRouteDetail detail : detailList) {
|
|
|
|
|
- detail.setRouteId(model.getId());
|
|
|
|
|
- jdbcClient.jdbcInsert(detail, connection);
|
|
|
|
|
|
|
+ if (null != detailList && !detailList.isEmpty()) {
|
|
|
|
|
+ ProcessRouteDetail routeDetail = new ProcessRouteDetail();
|
|
|
|
|
+ routeDetail.setRouteId(model.getId());
|
|
|
|
|
+ jdbcClient.jdbcRemove(routeDetail, connection);
|
|
|
|
|
+
|
|
|
|
|
+ for (ProcessRouteDetail detail : detailList) {
|
|
|
|
|
+ detail.setRouteId(model.getId());
|
|
|
|
|
+ jdbcClient.jdbcInsert(detail, connection);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
connection.commit();
|
|
connection.commit();
|
|
|
return new ResponseEntity<>(model, HttpStatus.OK);
|
|
return new ResponseEntity<>(model, HttpStatus.OK);
|
|
@@ -124,6 +142,17 @@ public class ProcessRouteController {
|
|
|
routeDetail.setRouteId(model.getId());
|
|
routeDetail.setRouteId(model.getId());
|
|
|
jdbcClient.jdbcRemove(routeDetail, connection);
|
|
jdbcClient.jdbcRemove(routeDetail, connection);
|
|
|
|
|
|
|
|
|
|
+ ProcessRoute history = new ProcessRoute();
|
|
|
|
|
+ history.setParentId(model.getId());
|
|
|
|
|
+ List<ProcessRoute> historyList = jdbcClient.getJdbcList(history, connection);
|
|
|
|
|
+ for (ProcessRoute hismodel : historyList) {
|
|
|
|
|
+ jdbcClient.jdbcRemoveById(hismodel, connection);
|
|
|
|
|
+
|
|
|
|
|
+ ProcessRouteDetail routeHisDetail = new ProcessRouteDetail();
|
|
|
|
|
+ routeHisDetail.setRouteId(hismodel.getId());
|
|
|
|
|
+ jdbcClient.jdbcRemove(routeHisDetail, connection);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
connection.commit();
|
|
connection.commit();
|
|
|
return new ResponseEntity<>(model, HttpStatus.OK);
|
|
return new ResponseEntity<>(model, HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -139,12 +168,27 @@ public class ProcessRouteController {
|
|
|
Connection connection = dataSource.getConnection();
|
|
Connection connection = dataSource.getConnection();
|
|
|
try {
|
|
try {
|
|
|
connection.setAutoCommit(false);
|
|
connection.setAutoCommit(false);
|
|
|
|
|
+ String newId = UUID.randomUUID().toString();
|
|
|
|
|
+
|
|
|
|
|
+ ProcessRoute existRoute = new ProcessRoute();
|
|
|
|
|
+ existRoute.setId(model.getId());
|
|
|
|
|
+ existRoute.setParentId(newId);
|
|
|
|
|
+ existRoute.setStatus(MESEnum.PROCESS_ROUTE_OF_STATUS_DISABLE.getValue());
|
|
|
|
|
+ jdbcClient.jdbcUpdateById(existRoute, connection);
|
|
|
|
|
+
|
|
|
|
|
+ ProcessRoute childrenRoute = new ProcessRoute();
|
|
|
|
|
+ childrenRoute.setParentId(newId);
|
|
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
+ paramMap.put("parentId", model.getId());
|
|
|
|
|
+ jdbcClient.jdbcUpdate(childrenRoute, paramMap, connection);
|
|
|
|
|
+
|
|
|
model.setCreateId(SecurityUtils.getCurrentUserId());
|
|
model.setCreateId(SecurityUtils.getCurrentUserId());
|
|
|
if (StringUtil.isEmpty(model.getCode())) {
|
|
if (StringUtil.isEmpty(model.getCode())) {
|
|
|
model.setCode(flowNoService.getFlowNo(MESEnum.FLOW_NO_TYPE_PROCESS_ROUTE.getValue(), connection));
|
|
model.setCode(flowNoService.getFlowNo(MESEnum.FLOW_NO_TYPE_PROCESS_ROUTE.getValue(), connection));
|
|
|
}
|
|
}
|
|
|
- model.setParentId(model.getId());
|
|
|
|
|
- model.setId(UUID.randomUUID().toString());
|
|
|
|
|
|
|
+ model.setParentId("0");
|
|
|
|
|
+ model.setId(newId);
|
|
|
|
|
+ model.setStatus(MESEnum.PROCESS_ROUTE_OF_STATUS_ENABLE.getValue());
|
|
|
jdbcClient.jdbcInsert(model, connection);
|
|
jdbcClient.jdbcInsert(model, connection);
|
|
|
|
|
|
|
|
List<ProcessRouteDetail> detailList = model.getDetailList();
|
|
List<ProcessRouteDetail> detailList = model.getDetailList();
|
|
@@ -161,4 +205,41 @@ public class ProcessRouteController {
|
|
|
connection.close();
|
|
connection.close();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping(value = "/regrade")
|
|
|
|
|
+ public Object regrade(@RequestBody ProcessRoute model) throws Exception {
|
|
|
|
|
+ Connection connection = dataSource.getConnection();
|
|
|
|
|
+ try {
|
|
|
|
|
+ connection.setAutoCommit(false);
|
|
|
|
|
+ ProcessRoute children = new ProcessRoute();
|
|
|
|
|
+ children.setParentId(model.getId());
|
|
|
|
|
+ List<ProcessRoute> childrenList = jdbcClient.getJdbcList(children, connection);
|
|
|
|
|
+ if (!childrenList.isEmpty()) {
|
|
|
|
|
+ childrenList = childrenList.stream().sorted(Comparator.comparing(ProcessRoute::getCreateTime).reversed()).collect(Collectors.toList());
|
|
|
|
|
+ ProcessRoute child = childrenList.get(0);
|
|
|
|
|
+ child.setParentId("0");
|
|
|
|
|
+ jdbcClient.jdbcUpdateById(child, connection);
|
|
|
|
|
+
|
|
|
|
|
+ ProcessRoute childrenRoute = new ProcessRoute();
|
|
|
|
|
+ childrenRoute.setParentId(child.getId());
|
|
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
+ paramMap.put("parentId", model.getId());
|
|
|
|
|
+ jdbcClient.jdbcUpdate(childrenRoute, paramMap, connection);
|
|
|
|
|
+
|
|
|
|
|
+ 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();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|