|
|
@@ -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);
|