addLocationApi.java 2.35 KB
package com.huaheng.api.general.Controller;

import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.location.domain.Location;
import com.huaheng.pc.general.location.service.ILocationService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 选择性批量新增库位,可选批量新增库位起始点
 */
@RestController
@RequestMapping("/api/location")
public class addLocationApi {

    @Autowired
    private ILocationService locationService;

    /**
     * 选择性批量新增保存库位
     */
    @Log(title = "接口-新增库位", operating = "新增库位", action = BusinessType.INSERT)
    @PostMapping("/adds")
    @ResponseBody
    public AjaxResult addlocations(@RequestBody Location lastLocation , Location lone)  {
        int startrow = lone.getRow();
        int startline = lone.getLine();
        int startlayer = lone.getLayer();
        int startgrid = lone.getGrid();
        int row = lastLocation.getRow().intValue();
        int line = lastLocation.getLine().intValue();
        int layer = lastLocation.getLayer().intValue();
        int grid = lastLocation.getGrid().intValue();
        for (int i=startrow; i<=row; i++)  {
            for (int j=startline; j<=line; j++)  {
                for (int k=startlayer; k<=layer; k++)  {
                    for (int m=startgrid; m<=grid; m++)  {
                        //Integer roadway = (j / 2) + 1;
                        Location location = new Location();
                        location.setRow(i);
                        location.setLine(j);
                        location.setLayer(k);
                        location.setGrid(m);
                        location.setZoneId(lastLocation.getZoneId());
                        location.setZoneCode(lastLocation.getZoneCode());
                        location.setType(lastLocation.getType());
                        location.setRoadway(lastLocation.getRoadway());
                        location.setEnable(lastLocation.getEnable());
                        locationService.insertLocation(location);
                    }
                }
            }
        }
        return  AjaxResult.success("");
    }
}