From 1707d15796d7dc78812f19b9c34868c8cb38a714 Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期日, 15 十月 2023 17:56:57 +0800 Subject: [PATCH] broker 卡车公司端 --- src/main/java/com/stylefeng/guns/modular/system/controller/RatesController.java | 89 ++++++++++++++++++++++++++++---------------- 1 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/stylefeng/guns/modular/system/controller/RatesController.java b/src/main/java/com/stylefeng/guns/modular/system/controller/RatesController.java index 674c737..9b49fd9 100644 --- a/src/main/java/com/stylefeng/guns/modular/system/controller/RatesController.java +++ b/src/main/java/com/stylefeng/guns/modular/system/controller/RatesController.java @@ -2,36 +2,28 @@ 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.mapper.Wrapper; import com.baomidou.mybatisplus.plugins.Page; -import com.stylefeng.guns.modular.system.dao.TCompanyFeeSettingMapper; +import com.stylefeng.guns.core.util.ToolUtil; 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.HashMap; 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 +47,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 +83,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 +101,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 +164,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); } }); @@ -250,26 +243,26 @@ @ApiImplicitParam(name = "id", value = "港区id/特殊码头id", required = true, dataType = "int",paramType = "query"), @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"), + @ApiImplicitParam(name = "code", value = "code", required = false, dataType = "String",paramType = "query"), }) @GetMapping(value = "/getWarehouseFromId") @ResponseBody - public Object getWarehouseFromId(int id,int pageNumber,int pageSize) { + public Object getWarehouseFromId(int id,int pageNumber,int pageSize,String code) { Page<TWarehouse> tWarehousePage = new Page<>(pageNumber, pageSize); - Page<TWarehouse> tWarehouses = warehouseService.selectPage(tWarehousePage,new EntityWrapper<TWarehouse>().eq("port_id", id)); - return new SuccessTip(tWarehouses); + List<TWarehouse> tWarehouses = warehouseService.getWarehouseFromId(tWarehousePage,id,code); + tWarehousePage.setRecords(tWarehouses); + return new SuccessTip(tWarehousePage); } @ApiOperation(value = "卡车公司- 根据id统一设置亚马逊价格",notes="卡车公司-根据id统一设置亚马逊价格") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), - @ApiImplicitParam(name = "id", value = "港区id/特殊码头id", required = true, dataType = "int",paramType = "query"), - @ApiImplicitParam(name = "money", value = "money", required = true, dataType = "double",paramType = "query"), }) - @GetMapping(value = "/setWarehousePrice") + @PostMapping(value = "/setWarehousePrice") @ResponseBody - public Object setWarehousePrice(int id,double money) { - List<TWarehouse> tWarehouses = warehouseService.selectList(new EntityWrapper<TWarehouse>().eq("port_id", id)); - tWarehouses.stream().forEach(e->e.setWarePrice(new BigDecimal(money))); + public Object setWarehousePrice(@RequestBody SetWarehouseDto dto) { + List<TWarehouse> tWarehouses = warehouseService.selectList(new EntityWrapper<TWarehouse>().in("id", dto.getId())); + tWarehouses.stream().forEach(e->e.setWarePrice(new BigDecimal(dto.getMoney()))); warehouseService.updateBatchById(tWarehouses); return new SuccessTip(tWarehouses); } @@ -293,7 +286,37 @@ } + @ApiOperation(value = "卡车公司- 点对点/范围/距离详情",notes="卡车公司-点对点/范围/距离详情") + @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"), + }) + @PostMapping(value = "/laneInfo") + @ResponseBody + public Object laneInfo( int id) { + TCompanyBasic tCompanyBasic = basicService.selectById(id); + HashMap<String, Object> map = new HashMap<>(); + map.put("data",tCompanyBasic); + + if(tCompanyBasic.getType()==2){ + String lonLat = tCompanyBasic.getLonLat(); + String[] split = lonLat.split("_"); + ArrayList<LonLat> lonLats = new ArrayList<>(); + for (String s : split) { + String[] split1 = s.split(","); + LonLat lonLat1 = new LonLat(); + lonLat1.setLat(split1[0]); + lonLat1.setLng(split1[1]); + lonLats.add(lonLat1); + } + map.put("lonlat",lonLats); + }else { + map.put("lonlat",new ArrayList<>()); + } + return new SuccessTip(tCompanyBasic); + } @ApiOperation(value = "卡车公司- 添加点对点/范围/距离",notes="卡车公司-添加点对点/范围/距离") + @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), }) @@ -334,12 +357,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,9 +373,11 @@ @PostMapping(value = "/addFee") @ResponseBody public Object addFee(@RequestBody List<TCompanyFeeSetting> feeSettings) { - Integer id1 = UserInfoUtil.getId(); - feeSettings.forEach(e->e.setCompanyId(id1)); - tCompanyFeeSettingMapper.insertBatch(feeSettings); + if(feeSettings.get(0).getId()==null){ + tCompanyFeeSettingMapper.insertBatch(feeSettings); + }else { + tCompanyFeeSettingMapper.updateBatchById(feeSettings); + } return new SuccessTip(); } -- Gitblit v1.7.1