liujie
2023-05-15 6225c37d2f53adf26daf6b4859af5fb5c6fad088
src/main/java/com/stylefeng/guns/modular/system/controller/RatesController.java
@@ -2,36 +2,25 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.modular.system.dao.TCompanyFeeSettingMapper;
import com.stylefeng.guns.modular.system.dao.TPortMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.utils.UserInfoUtil;
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
@Controller
@Api(tags = "费用设置")
@@ -55,12 +44,12 @@
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "id", value = "当前公司id", required = true, dataType = "int",paramType = "query"),
    })
    @GetMapping(value = "/metroList")
    @ResponseBody
    public Object metroList(int pageNumber,int pageSize) {
    public Object metroList(int pageNumber,int pageSize,int id) {
        Page<TRates> tRatesPage = new Page<>(pageNumber, pageSize);
        Integer id = UserInfoUtil.getId();
        Page<TRates> tRates = ratesService.selectPage(tRatesPage,new EntityWrapper<TRates>().eq("company_id", id).eq("type", 1));
        Page<TRatesVo> tRatesVoPage = new Page<>();
        BeanUtil.copyProperties(tRates,tRatesVoPage);
@@ -91,12 +80,12 @@
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "id", value = "当前公司id", required = true, dataType = "int",paramType = "query"),
    })
    @GetMapping(value = "/specialPortList")
    @ResponseBody
    public Object specialPortList(int pageNumber,int pageSize) {
    public Object specialPortList(int pageNumber,int pageSize,int id) {
        Page<TRates> tRatesPage = new Page<>(pageNumber, pageSize);
        Integer id = UserInfoUtil.getId();
        Page<TRates> tRates = ratesService.selectPage(tRatesPage,new EntityWrapper<TRates>().eq("company_id", id).eq("type", 2));
        Page<TRatesVoOne> tRatesVoPage = new Page<>();
        BeanUtil.copyProperties(tRates,tRatesVoPage);
@@ -109,6 +98,7 @@
            TPort tPort = tPortMapper.selectById(record.getMetroId());
            tRatesVo.setAddress(tPort.getAddress());
            tRatesVo.setZipCode(tPort.getZipCode());
            tRatesVo.setPortName(tPort.getName());
            TCountry tCountry = countryService.selectById(tPort.getCity());
            tRatesVo.setMetro(tCountry.getName());
            // state
@@ -171,13 +161,13 @@
        ratesService.insert(tRates);
        List<TWarehouse> tWarehouses = warehouseService.selectList(new EntityWrapper<TWarehouse>().eq("company_id", 0));
        tWarehouses.stream().forEach(e->{
            e.setCompanyId(UserInfoUtil.getId());
            e.setPortId(tRates.getId());
                e.setPortId(tRates.getId());
        });
        ExecutorService executorService = Executors.newCachedThreadPool();
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                tWarehouses.forEach(e->e.setCompanyId(tRates.getCompanyId()));
                warehouseService.insertBatch(tWarehouses);
            }
        });
@@ -334,12 +324,12 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "companyId", value = "当前公司id", required = true, dataType = "int",paramType = "query"),
    })
    @GetMapping(value = "/getFee")
    @ResponseBody
    public Object getFee( int id) {
        Integer id1 = UserInfoUtil.getId();
        List<TCompanyFeeSetting> feeSettings = tCompanyFeeSettingMapper.selectList(new EntityWrapper<TCompanyFeeSetting>().eq("rates_id", id).eq("company_id", id1));
    public Object getFee( int id,int companyId) {
        List<TCompanyFeeSetting> feeSettings = tCompanyFeeSettingMapper.selectList(new EntityWrapper<TCompanyFeeSetting>().eq("rates_id", id).eq("company_id", companyId));
        return new SuccessTip(feeSettings);
    }
@@ -350,8 +340,6 @@
    @PostMapping(value = "/addFee")
    @ResponseBody
    public Object addFee(@RequestBody List<TCompanyFeeSetting> feeSettings) {
        Integer id1 = UserInfoUtil.getId();
        feeSettings.forEach(e->e.setCompanyId(id1));
        tCompanyFeeSettingMapper.insertBatch(feeSettings);
        return new SuccessTip();
    }