#
vincentlu
2 天以前 9cea4833f937cd6dfb49299d0240215581c79188
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/RouteController.java
@@ -2,7 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.acs.common.constant.CommonConstant;
import com.zy.acs.common.utils.QrCodeCodecSupport;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
@@ -106,6 +106,7 @@
    @PreAuthorize("hasAuthority('manager:route:update')")
    @OperationLog("Update Route")
    @PostMapping("/route/update")
    @Transactional
    public R update(@RequestBody Route route) {
        Route origin = routeService.getById(route.getId());
        if (origin == null) {
@@ -131,6 +132,14 @@
        if (!routeService.updateById(route)) {
            return R.error("Update Fail");
        }
        Code startCode = codeService.getCacheById(route.getStartCode());
        Code endCode = codeService.getCacheById(route.getEndCode());
        if (startCode != null && endCode != null) {
            codeGapService.createCodeGapByCode(startCode, endCode, getLoginUserId());
        }
        if (!isSameCode(origin, route)) {
            codeGapService.removeCodeGapIfUnused(origin.getStartCode(), origin.getEndCode());
        }
        List<Long> affectedCodeIds = new ArrayList<>();
        if (origin.getStartCode() != null) {
            affectedCodeIds.add(origin.getStartCode());
@@ -151,6 +160,7 @@
    @PreAuthorize("hasAuthority('manager:route:remove')")
    @OperationLog("Delete Route")
    @PostMapping("/route/remove/{ids}")
    @Transactional
    public R remove(@PathVariable Long[] ids) {
        List<Route> routes = routeService.listByIds(Arrays.asList(ids));
        List<Long> affectedCodeIds = new ArrayList<>();
@@ -164,6 +174,9 @@
        }
        if (!routeService.removeByIds(Arrays.asList(ids))) {
            return R.error("Delete Fail");
        }
        for (Route route : routes) {
            codeGapService.removeCodeGapIfUnused(route.getStartCode(), route.getEndCode());
        }
        codeService.refreshCornerByCodeIds(affectedCodeIds);
        return R.ok("Delete Success").add(ids);
@@ -206,10 +219,10 @@
                key = Utils.toCamelCase(key);
                one.put(key, entry.getValue());
            }
            RouteExcel excelDto = Cools.conver(one, RouteExcel.class);
            RouteExcel excelDto = Cools.convert(one, RouteExcel.class);
            Code code0 = codeService.getCacheByData(Utils.zeroFill(excelDto.getStartCode(), CommonConstant.QR_CODE_LEN));
            Code code1 = codeService.getCacheByData(Utils.zeroFill(excelDto.getEndCode(), CommonConstant.QR_CODE_LEN));
            Code code0 = codeService.getCacheByData(excelDto.getStartCode());
            Code code1 = codeService.getCacheByData(excelDto.getEndCode());
            if (null == code0 || null == code1) { continue; }
@@ -219,4 +232,11 @@
        return R.ok();
    }
    private boolean isSameCode(Route route0, Route route1) {
        return Objects.equals(route0.getStartCode(), route1.getStartCode())
                && Objects.equals(route0.getEndCode(), route1.getEndCode())
                || Objects.equals(route0.getStartCode(), route1.getEndCode())
                && Objects.equals(route0.getEndCode(), route1.getStartCode());
    }
}