#
luxiaotao1123
2024-09-23 4fe1a741d807b55f7fc14aed85e232b9d7972425
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.utils.GsonUtils;
import com.zy.acs.common.constant.CommonConstant;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
@@ -10,8 +10,11 @@
import com.zy.acs.manager.common.domain.BaseParam;
import com.zy.acs.manager.common.domain.KeyValVo;
import com.zy.acs.manager.common.domain.PageParam;
import com.zy.acs.manager.common.domain.RouteExcel;
import com.zy.acs.manager.common.utils.ExcelUtil;
import com.zy.acs.manager.manager.entity.Code;
import com.zy.acs.manager.manager.entity.Route;
import com.zy.acs.manager.manager.service.CodeGapService;
import com.zy.acs.manager.manager.service.CodeService;
import com.zy.acs.manager.manager.service.RouteService;
import com.zy.acs.manager.system.controller.BaseController;
@@ -32,6 +35,8 @@
    private RouteService routeService;
    @Autowired
    private CodeService codeService;
    @Autowired
    private CodeGapService codeGapService;
    @PreAuthorize("hasAuthority('manager:route:list')")
    @PostMapping("/route/page")
@@ -63,6 +68,21 @@
    @OperationLog("Create Route")
    @PostMapping("/route/save")
    public R save(@RequestBody Route route) {
        if (route.getStartCode() == null || route.getEndCode() == null) {
            return R.error("Save Fail");
        }
        if (route.getStartCode().equals(route.getEndCode())) {
            return R.error("Save Fail");
        }
        if (routeService.count(new LambdaQueryWrapper<Route>()
                .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
        ) {
            return R.error("Save Fail");
        }
        route.setCreateBy(getLoginUserId());
        route.setCreateTime(new Date());
        route.setUpdateBy(getLoginUserId());
@@ -77,6 +97,9 @@
    @OperationLog("Update Route")
    @PostMapping("/route/update")
    public R update(@RequestBody Route route) {
        if (route.getStartCode().equals(route.getEndCode())) {
            return R.error("Update Fail");
        }
        route.setUpdateBy(getLoginUserId());
        route.setUpdateTime(new Date());
        if (!routeService.updateById(route)) {
@@ -118,7 +141,7 @@
    @PreAuthorize("hasAuthority('manager:route:save')")
    @PostMapping("/route/import")
    public R importBatch(@RequestBody List<Map<String, Object>> list) {
        Date now = new Date();  Long userId = getLoginUserId();
        Long userId = getLoginUserId();
        String regex = "([a-zA-Z]+)\\(";
        Pattern pattern = Pattern.compile(regex);
        for (Map<String, Object> map : list) {
@@ -132,8 +155,15 @@
                key = Utils.toCamelCase(key);
                one.put(key, entry.getValue());
            }
            Route route = Cools.conver(one, Route.class);
            System.out.println(GsonUtils.toJson(route));
            RouteExcel excelDto = Cools.conver(one, RouteExcel.class);
            Code code0 = codeService.selectByData(Utils.zeroFill(excelDto.getStartCode(), CommonConstant.QR_CODE_LEN));
            Code code1 = codeService.selectByData(Utils.zeroFill(excelDto.getEndCode(), CommonConstant.QR_CODE_LEN));
            if (null == code0 || null == code1) { continue; }
            routeService.createRouteByCode(code0, code1, excelDto.getDirection(), userId);
            codeGapService.createCodeGapByCode(code0, code1, userId);
        }
        return R.ok();
    }