package com.stylefeng.guns.modular.system.controller;
|
|
|
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 = "费用设置")
|
@RequestMapping("/api/rates")
|
public class RatesController {
|
|
@Resource
|
private ITRatesService ratesService;
|
|
@Resource
|
private ITCountryService countryService;
|
|
@Resource
|
private IWarehouseService warehouseService;
|
@Resource
|
private ITCompanyBasicService basicService;
|
|
|
@ApiOperation(value = "卡车公司-获取港区设置列表",notes="卡车公司-获取港区设置列表")
|
@ApiImplicitParams({
|
@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"),
|
})
|
@GetMapping(value = "/metroList")
|
@ResponseBody
|
public Object metroList(int pageNumber,int pageSize) {
|
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);
|
ArrayList<TRatesVo> tRatesVos = new ArrayList<>();
|
for (TRates record : tRates.getRecords()) {
|
TRatesVo tRatesVo = new TRatesVo();
|
tRatesVo.setId(record.getId());
|
tRatesVo.setRemarks(record.getRemarks());
|
// city
|
TCountry tCountry = countryService.selectById(record.getMetroId());
|
tRatesVo.setMetro(tCountry.getName());
|
tRatesVo.setZipCode(tCountry.getZipCode());
|
// state
|
TCountry tCountry1 = countryService.selectById(tCountry.getParentId());
|
tRatesVo.setState(tCountry1.getName());
|
|
tRatesVos.add(tRatesVo);
|
}
|
tRatesVoPage.setRecords(tRatesVos);
|
return new SuccessTip(tRatesVoPage);
|
}
|
|
@Resource
|
private TPortMapper tPortMapper;
|
|
@ApiOperation(value = "卡车公司-获取特殊码头列表",notes="卡车公司-获取特殊码头列表")
|
@ApiImplicitParams({
|
@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"),
|
})
|
@GetMapping(value = "/specialPortList")
|
@ResponseBody
|
public Object specialPortList(int pageNumber,int pageSize) {
|
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);
|
ArrayList<TRatesVoOne> tRatesVos = new ArrayList<>();
|
for (TRates record : tRates.getRecords()) {
|
TRatesVoOne tRatesVo = new TRatesVoOne();
|
tRatesVo.setId(record.getId());
|
tRatesVo.setRemarks(record.getRemarks());
|
// city
|
TPort tPort = tPortMapper.selectById(record.getMetroId());
|
tRatesVo.setAddress(tPort.getAddress());
|
tRatesVo.setZipCode(tPort.getZipCode());
|
TCountry tCountry = countryService.selectById(tPort.getCity());
|
tRatesVo.setMetro(tCountry.getName());
|
// state
|
TCountry tCountry1 = countryService.selectById(tCountry.getParentId());
|
tRatesVo.setState(tCountry1.getName());
|
|
tRatesVos.add(tRatesVo);
|
}
|
tRatesVoPage.setRecords(tRatesVos);
|
return new SuccessTip(tRatesVoPage);
|
}
|
|
@ApiOperation(value = "卡车公司-获取所有port",notes="卡车公司-获取所有port")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@GetMapping(value = "/portList")
|
@ResponseBody
|
public Object portList() {
|
List<TPort> tCountries = tPortMapper.selectList(new EntityWrapper<TPort>().eq("remove", 0));
|
return new SuccessTip(tCountries);
|
}
|
|
|
@ApiOperation(value = "卡车公司-获取所有state",notes="卡车公司-获取所有state")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@GetMapping(value = "/stateList")
|
@ResponseBody
|
public Object stateList() {
|
List<TCountry> tCountries = countryService.selectList(new EntityWrapper<TCountry>().eq("type", 2).eq("remove", 0));
|
return new SuccessTip(tCountries);
|
}
|
|
|
@ApiOperation(value = "卡车公司-根据stateId获取所有city",notes="卡车公司-根据stateId获取所有city")
|
@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"),
|
|
})
|
@GetMapping(value = "/cityList")
|
@ResponseBody
|
public Object cityList(int id) {
|
List<TCountry> tCountries = countryService.selectList(new EntityWrapper<TCountry>().eq("type", 3).eq("remove", 0).eq("parent_id",id));
|
return new SuccessTip(tCountries);
|
}
|
|
|
|
@ApiOperation(value = "卡车公司- 添加港区设置/特殊码头",notes="卡车公司-添加港区设置/特殊码头")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
|
})
|
@PostMapping(value = "/addMetro")
|
@ResponseBody
|
public Object addMetro(@RequestBody TRates tRates) {
|
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());
|
});
|
ExecutorService executorService = Executors.newCachedThreadPool();
|
executorService.submit(new Runnable() {
|
@Override
|
public void run() {
|
warehouseService.insertBatch(tWarehouses);
|
}
|
});
|
|
return new SuccessTip();
|
}
|
|
@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"),
|
})
|
@GetMapping(value = "/metroInfo")
|
@ResponseBody
|
public Object metroInfo(int id) {
|
TRatesInfo tRatesInfo = new TRatesInfo();
|
TRates tRates = ratesService.selectById(id);
|
tRatesInfo.setId(tRates.getId());
|
tRatesInfo.setRemarks(tRates.getRemarks());
|
tRatesInfo.setMetroId(tRates.getMetroId());
|
TCountry tCountry = countryService.selectById(tRates.getMetroId());
|
tRatesInfo.setStateId(tCountry.getParentId());
|
return new SuccessTip(tRatesInfo);
|
}
|
|
@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"),
|
})
|
@GetMapping(value = "/specialPortInfo")
|
@ResponseBody
|
public Object specialPortInfo(int id) {
|
TRatesInfoOne tRatesInfo = new TRatesInfoOne();
|
TRates tRates = ratesService.selectById(id);
|
tRatesInfo.setId(tRates.getId());
|
tRatesInfo.setRemarks(tRates.getRemarks());
|
tRatesInfo.setPortId(tRates.getMetroId());
|
return new SuccessTip(tRatesInfo);
|
}
|
|
@ApiOperation(value = "卡车公司- 修改港区设置",notes="卡车公司-修改港区设置")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@PostMapping(value = "/updateMetro")
|
@ResponseBody
|
public Object updateMetro(@RequestBody TRates tRates) {
|
ratesService.updateById(tRates);
|
return new SuccessTip();
|
}
|
|
@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"),
|
})
|
@GetMapping(value = "/deleteMetro")
|
@ResponseBody
|
public Object deleteMetro( int id) {
|
ratesService.deleteById(id);
|
warehouseService.delete(new EntityWrapper<TWarehouse>().eq("port_id",id));
|
return new SuccessTip();
|
}
|
|
|
@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/特殊码头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"),
|
})
|
@GetMapping(value = "/getWarehouseFromId")
|
@ResponseBody
|
public Object getWarehouseFromId(int id,int pageNumber,int pageSize) {
|
Page<TWarehouse> tWarehousePage = new Page<>(pageNumber, pageSize);
|
Page<TWarehouse> tWarehouses = warehouseService.selectPage(tWarehousePage,new EntityWrapper<TWarehouse>().eq("port_id", id));
|
return new SuccessTip(tWarehouses);
|
}
|
|
@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")
|
@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)));
|
warehouseService.updateBatchById(tWarehouses);
|
return new SuccessTip(tWarehouses);
|
}
|
|
|
|
@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 = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "type", value = "1/2/3 点对点/范围/距离", required = true, dataType = "int",paramType = "query"),
|
})
|
@GetMapping(value = "/getLane")
|
@ResponseBody
|
public Object getLane(int id,int pageNumber,int pageSize,int type) {
|
Page<TCompanyBasic> tCompanyBasicPage = new Page<>(pageNumber, pageSize);
|
Page<TCompanyBasic> basicPage = basicService.selectPage(tCompanyBasicPage,new EntityWrapper<TCompanyBasic>().eq("port_id", id).eq("type",type));
|
return new SuccessTip(basicPage);
|
}
|
|
|
@ApiOperation(value = "卡车公司- 添加点对点/范围/距离",notes="卡车公司-添加点对点/范围/距离")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@PostMapping(value = "/addLane")
|
@ResponseBody
|
public Object addLane(@RequestBody TCompanyBasic basic) {
|
basicService.insert(basic);
|
return new SuccessTip();
|
}
|
|
|
@ApiOperation(value = "卡车公司- 编辑点对点/范围/距离",notes="卡车公司-编辑点对点/范围/距离")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@PostMapping(value = "/updateLane")
|
@ResponseBody
|
public Object updateLane(@RequestBody TCompanyBasic basic) {
|
basicService.updateById(basic);
|
return new SuccessTip();
|
}
|
|
@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"),
|
})
|
@GetMapping(value = "/delLane")
|
@ResponseBody
|
public Object delLane( int id) {
|
basicService.deleteById(id);
|
return new SuccessTip();
|
}
|
|
@Resource
|
private ITCompanyFeeSettingService tCompanyFeeSettingMapper;
|
@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", 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));
|
return new SuccessTip(feeSettings);
|
}
|
|
@ApiOperation(value = "卡车公司- 添加费用",notes="卡车公司-添加费用\"")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@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();
|
}
|
|
|
@ApiOperation(value = "卡车公司- 修改费用",notes="卡车公司-修改费用")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@PostMapping(value = "/updateFee")
|
@ResponseBody
|
public Object updateFee(@RequestBody List<TCompanyFeeSetting> feeSettings) {
|
tCompanyFeeSettingMapper.updateBatchById(feeSettings);
|
return new SuccessTip();
|
}
|
|
|
|
}
|