| | |
| | | }, |
| | | }, |
| | | }, |
| | | route: { |
| | | enums: { |
| | | direction: { |
| | | forward: 'Forward', |
| | | reverse: 'Reverse', |
| | | unordered: 'Unordered', |
| | | }, |
| | | }, |
| | | }, |
| | | } |
| | | }; |
| | | |
| | |
| | | }, |
| | | }, |
| | | }, |
| | | route: { |
| | | enums: { |
| | | direction: { |
| | | forward: '正向', |
| | | reverse: '反向', |
| | | unordered: '无序', |
| | | }, |
| | | }, |
| | | }, |
| | | } |
| | | }; |
| | | |
| | |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.code.concer" |
| | | source="concer" |
| | | choices={[ |
| | | { id: 1, name: '是' }, |
| | | { id: 0, name: '否' }, |
| | | ]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.code.x" |
| | | source="x" |
| | |
| | | <NumberInput |
| | | label="table.field.code.y" |
| | | source="y" |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.code.concer" |
| | | source="concer" |
| | | choices={[ |
| | | { id: 1, name: '是' }, |
| | | { id: 0, name: '否' }, |
| | | ]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | |
| | | </DialogTitle> |
| | | <DialogContent> |
| | | <Grid container rowSpacing={2} columnSpacing={2}> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.route.uuid" |
| | | source="uuid" |
| | | parse={v => v} |
| | | autoFocus |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.route.name" |
| | | source="name" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | </Grid> */} |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <ReferenceInput |
| | | source="startCode" |
| | |
| | | /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.route.codeArr" |
| | | source="codeArr" |
| | |
| | | source="codeDataArr" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | </Grid> */} |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.route.direction" |
| | | source="direction" |
| | | choices={[ |
| | | { id: 0, name: '无序' }, |
| | | { id: 1, name: '正向' }, |
| | | { id: 2, name: '反向' }, |
| | | { id: 0, name: 'page.route.enums.direction.unordered' }, |
| | | { id: 1, name: 'page.route.enums.direction.forward' }, |
| | | { id: 2, name: 'page.route.enums.direction.reverse' }, |
| | | ]} |
| | | validate={required()} |
| | | /> |
| | | </Grid> |
| | | |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <StatusSelectInput /> |
| | | </Grid> |
| | |
| | | <Typography variant="h6" gutterBottom> |
| | | {translate('common.edit.title.main')} |
| | | </Typography> |
| | | <Stack direction='row' gap={2}> |
| | | {/* <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.route.uuid" |
| | | source="uuid" |
| | | parse={v => v} |
| | | autoFocus |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.route.name" |
| | | source="name" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | </Stack> */} |
| | | <Stack direction='row' gap={2}> |
| | | <ReferenceInput |
| | | source="startCode" |
| | |
| | | validate={required()} |
| | | /> |
| | | </ReferenceInput> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <ReferenceInput |
| | | source="endCode" |
| | | reference="code" |
| | |
| | | </ReferenceInput> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.route.codeArr" |
| | | source="codeArr" |
| | | parse={v => v} |
| | | validate={required()} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.route.codeDataArr" |
| | | source="codeDataArr" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <SelectInput |
| | | label="table.field.route.direction" |
| | | source="direction" |
| | | choices={[ |
| | | { id: 0, name: '无序' }, |
| | | { id: 1, name: '正向' }, |
| | | { id: 2, name: '反向' }, |
| | | { id: 0, name: 'page.route.enums.direction.unordered' }, |
| | | { id: 1, name: 'page.route.enums.direction.forward' }, |
| | | { id: 2, name: 'page.route.enums.direction.reverse' }, |
| | | ]} |
| | | validate={required()} |
| | | /> |
| | |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | FunctionField, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | |
| | | <TextInput source="codeDataArr" label="table.field.route.codeDataArr" />, |
| | | <SelectInput source="direction" label="table.field.route.direction" |
| | | choices={[ |
| | | { id: 0, name: '无序' }, |
| | | { id: 1, name: '正向' }, |
| | | { id: 2, name: '反向' }, |
| | | { id: 0, name: 'page.route.enums.direction.unordered' }, |
| | | { id: 1, name: 'page.route.enums.direction.forward' }, |
| | | { id: 2, name: 'page.route.enums.direction.reverse' }, |
| | | ]} |
| | | alwaysOn |
| | | />, |
| | |
| | | </ReferenceField> |
| | | <TextField source="codeArr" label="table.field.route.codeArr" /> |
| | | <TextField source="codeDataArr" label="table.field.route.codeDataArr" /> |
| | | <TextField source="direction$" label="table.field.route.direction" sortable={false} /> |
| | | |
| | | <FunctionField |
| | | label="table.field.route.direction" |
| | | sortable={false} |
| | | render={(record) => { |
| | | switch (record.direction) { |
| | | case 0: |
| | | return translate('page.route.enums.direction.unordered'); |
| | | case 1: |
| | | return translate('page.route.enums.direction.forward'); |
| | | case 2: |
| | | return translate('page.route.enums.direction.reverse'); |
| | | default: |
| | | return ''; |
| | | } |
| | | }} |
| | | /> |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | |
| | | import com.zy.acs.common.utils.Utils; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.domain.BaseParam; |
| | | import com.zy.acs.manager.common.domain.KeyValVo; |
| | |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | @PreAuthorize("hasAuthority('manager:route:save')") |
| | | @OperationLog("Create Route") |
| | | @PostMapping("/route/save") |
| | | @Transactional |
| | | public R save(@RequestBody Route route) { |
| | | if (route.getStartCode() == null || route.getEndCode() == null) { |
| | | return R.error("Save Fail"); |
| | |
| | | .eq(Route::getStartCode, route.getStartCode()) |
| | | .eq(Route::getEndCode, route.getEndCode())) > 0 || |
| | | routeService.count(new LambdaQueryWrapper<Route>() |
| | | .eq(Route::getStartCode, route.getStartCode()) |
| | | .eq(Route::getEndCode, route.getEndCode())) > 0 |
| | | .eq(Route::getStartCode, route.getEndCode()) |
| | | .eq(Route::getEndCode, route.getStartCode())) > 0 |
| | | ) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | route.setCreateBy(getLoginUserId()); |
| | | route.setCreateTime(new Date()); |
| | | route.setUpdateBy(getLoginUserId()); |
| | | route.setUpdateTime(new Date()); |
| | | if (!routeService.save(route)) { |
| | | |
| | | Code startCode = codeService.getById(route.getStartCode()); |
| | | Code endCode = codeService.getById(route.getEndCode()); |
| | | |
| | | if (null == startCode || null == endCode) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | |
| | | Route result = routeService.createRouteByCode(startCode, endCode, route.getDirection(), getLoginUserId()); |
| | | codeGapService.createCodeGapByCode(startCode, endCode, getLoginUserId()); |
| | | |
| | | if (null == result) { |
| | | throw new CoolException("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(route); |
| | | } |
| | |
| | | if (route.getStartCode().equals(route.getEndCode())) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | if (routeService.count(new LambdaQueryWrapper<Route>() |
| | | .eq(Route::getStartCode, route.getStartCode()) |
| | | .eq(Route::getEndCode, route.getEndCode()) |
| | | .ne(Route::getId, route.getId())) > 0 || |
| | | routeService.count(new LambdaQueryWrapper<Route>() |
| | | .eq(Route::getStartCode, route.getEndCode()) |
| | | .eq(Route::getEndCode, route.getStartCode()) |
| | | .ne(Route::getId, route.getId())) > 0 |
| | | ) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | |
| | | route.setUpdateBy(getLoginUserId()); |
| | | route.setUpdateTime(new Date()); |
| | | if (!routeService.updateById(route)) { |
| | |
| | | |
| | | public interface RouteService extends IService<Route> { |
| | | |
| | | Route createRouteByCode(Code code0, Code code1); |
| | | Route createRouteByCode(Code startCode, Code endCode); |
| | | |
| | | Route createRouteByCode(Code code0, Code code1, Integer direction, Long userId); |
| | | Route createRouteByCode(Code startCode, Code endCode, Integer direction, Long userId); |
| | | |
| | | List<String> findCodeDataOfSingle(Long code); |
| | | |
| | | Route findByCodeOfBoth(Long code0, Long code1); |
| | | Route findByCodeOfBoth(Long startCode, Long endCode); |
| | | |
| | | } |
| | |
| | | private CodeService codeService; |
| | | |
| | | @Override |
| | | public Route createRouteByCode(Code code0, Code code1) { |
| | | return createRouteByCode(code0, code1, 0, null); |
| | | public Route createRouteByCode(Code startCode, Code endCode) { |
| | | return createRouteByCode(startCode, endCode, 0, null); |
| | | } |
| | | |
| | | @Override |
| | | public Route createRouteByCode(Code code0, Code code1, Integer direction, Long userId) { |
| | | if (code0.getData().equals(code1.getData())) { |
| | | public Route createRouteByCode(Code startCode, Code endCode, Integer direction, Long userId) { |
| | | if (startCode.getData().equals(endCode.getData())) { |
| | | return null; |
| | | } |
| | | Route route = this.findByCodeOfBoth(code0.getId(), code1.getId()); |
| | | Route route = this.findByCodeOfBoth(startCode.getId(), endCode.getId()); |
| | | direction = Optional.ofNullable(direction).orElse(0); |
| | | if (null == route) { |
| | | Date now = new Date(); |
| | | route = new Route(); |
| | | route.setUuid(code0.getData() + "-" + code1.getData()); |
| | | route.setStartCode(code0.getId()); |
| | | route.setEndCode(code1.getId()); |
| | | route.setUuid(startCode.getData() + "-" + endCode.getData()); |
| | | route.setStartCode(startCode.getId()); |
| | | route.setEndCode(endCode.getId()); |
| | | route.setDirection(direction); |
| | | route.setCodeArr(GsonUtils.toJson(Arrays.asList(code0.getId(), code1.getId()))); |
| | | route.setCodeArr(GsonUtils.toJson(Arrays.asList(startCode.getId(), endCode.getId()))); |
| | | route.setCreateBy(userId); |
| | | route.setCreateTime(now); |
| | | route.setUpdateBy(userId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Route findByCodeOfBoth(Long code0, Long code1) { |
| | | Route route = getOne(new LambdaQueryWrapper<Route>().eq(Route::getStartCode, code0).eq(Route::getEndCode, code1).eq(Route::getStatus, 1)); |
| | | public Route findByCodeOfBoth(Long startCode, Long endCode) { |
| | | Route route = getOne(new LambdaQueryWrapper<Route>().eq(Route::getStartCode, startCode).eq(Route::getEndCode, endCode).eq(Route::getStatus, 1)); |
| | | if (null == route) { |
| | | route = getOne(new LambdaQueryWrapper<Route>().eq(Route::getEndCode, code0).eq(Route::getStartCode, code1).eq(Route::getStatus, 1)); |
| | | route = getOne(new LambdaQueryWrapper<Route>().eq(Route::getEndCode, startCode).eq(Route::getStartCode, endCode).eq(Route::getStatus, 1)); |
| | | } |
| | | return route; |
| | | } |