package com.stylefeng.guns.modular.system.service.impl;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.date.DateUtil;
|
import com.amazonaws.services.dynamodbv2.xspec.M;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.dao.*;
|
import com.stylefeng.guns.modular.system.model.*;
|
import com.stylefeng.guns.modular.system.model.vo.OrderDetailVo;
|
import com.stylefeng.guns.modular.system.model.vo.OrderInfoVo;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.utils.GoogleMap.FindPlaceFromTextVo;
|
import com.stylefeng.guns.modular.system.utils.GoogleMap.GoogleMapUtil;
|
import com.stylefeng.guns.modular.system.utils.UserInfoUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.math.BigInteger;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* <p>
|
* 服务实现类
|
* </p>
|
*
|
* @author stylefeng
|
* @since 2023-02-03
|
*/
|
@Service
|
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements ITOrderService {
|
|
@Resource
|
private TUserMapper tUserMapper;
|
|
@Resource
|
private UserMapper userMapper;
|
|
@Resource
|
private TGoodsMapper tGoodsMapper;
|
|
@Resource
|
private TCompanyMapper tCompanyMapper;
|
|
@Resource
|
private TPriceMapper priceMapper;
|
|
|
@Resource
|
private TGroupMapper tGroupMapper;
|
|
@Resource
|
private TQuoteMapper tQuoteMapper;
|
|
@Autowired
|
private ITBoxSizeService sizeService;
|
|
@Autowired
|
private GoogleMapUtil googleMapUtil;
|
|
@Resource
|
private TPortMapper portMapper;
|
|
@Resource
|
private WareHouseMapper wareHouseMapper;
|
|
@Resource
|
private DriverNoteMapper driverNoteMapper;
|
|
@Autowired
|
private ITDriverService driverService;
|
|
|
@Resource
|
private TCarriersMapper carriersMapper;
|
|
@Override
|
public List<ReceivableVo> getReceivable(Page<ReceivableVo> receivableVoPage, String time, String name) {
|
//TODO 时间保留
|
List<ReceivableVo> list = this.baseMapper.getReceivable(receivableVoPage,name);
|
|
Calendar instance = Calendar.getInstance();
|
instance.setTime(new Date());
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
String format = simpleDateFormat.format(new Date())+" 23:59:59";
|
// 30天
|
instance.add(Calendar.DATE,-30);
|
String time1 = simpleDateFormat.format(instance.getTime())+" 00:00:01";
|
// 60tian
|
instance.add(Calendar.DATE,-30);
|
String time2 = simpleDateFormat.format(instance.getTime())+" 00:00:01";
|
// 90tian
|
instance.add(Calendar.DATE,-30);
|
String time3 = simpleDateFormat.format(instance.getTime())+" 00:00:01";
|
|
for (ReceivableVo receivableVo : list) {
|
// 根据id获取30天内的金额
|
receivableVo.setTwentyDay(this.baseMapper.getTwentyDay(receivableVo.getUserId(),format,time1)==null?0:this.baseMapper.getTwentyDay(receivableVo.getUserId(),format,time1));
|
|
// 30-60tian
|
receivableVo.setThirtyDay(this.baseMapper.getTwentyDay(receivableVo.getUserId(),time1,time2)==null?0:this.baseMapper.getTwentyDay(receivableVo.getUserId(),time1,time2));
|
receivableVo.setSixtyDay(this.baseMapper.getTwentyDay(receivableVo.getUserId(),time2,time3)==null?0:this.baseMapper.getTwentyDay(receivableVo.getUserId(),time2,time3));
|
receivableVo.setNinetyDay(this.baseMapper.getNineDay(receivableVo.getUserId(),time3)==null?0:this.baseMapper.getNineDay(receivableVo.getUserId(),time3));
|
|
}
|
return list;
|
}
|
|
@Override
|
public List<ShouldPayVo> getPayList(Page<ShouldPayVo> receivableVoPage, String time, String name) {
|
List<ShouldPayVo> list = this.baseMapper.getPayList(receivableVoPage,name);
|
|
Calendar instance = Calendar.getInstance();
|
instance.setTime(new Date());
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
String format = simpleDateFormat.format(new Date())+" 23:59:59";
|
// 30天
|
instance.add(Calendar.DATE,-30);
|
String time1 = simpleDateFormat.format(instance.getTime())+" 00:00:01";
|
// 60tian
|
instance.add(Calendar.DATE,-30);
|
String time2 = simpleDateFormat.format(instance.getTime())+" 00:00:01";
|
// 90tian
|
instance.add(Calendar.DATE,-30);
|
String time3 = simpleDateFormat.format(instance.getTime())+" 00:00:01";
|
|
|
for (ShouldPayVo shouldPayVo : list) {
|
shouldPayVo.setTwentyDay(this.baseMapper.getTwentyDayPay(shouldPayVo.getUserId(),format,time1)==null?0:this.baseMapper.getTwentyDayPay(shouldPayVo.getUserId(),format,time1));
|
|
// 30-60tian
|
shouldPayVo.setThirtyDay(this.baseMapper.getTwentyDayPay(shouldPayVo.getUserId(),time1,time2)==null?0:this.baseMapper.getTwentyDayPay(shouldPayVo.getUserId(),time1,time2));
|
|
shouldPayVo.setSixtyDay(this.baseMapper.getTwentyDayPay(shouldPayVo.getUserId(),time2,time3)==null?0:this.baseMapper.getTwentyDayPay(shouldPayVo.getUserId(),time2,time3));
|
|
shouldPayVo.setNinetyDay(this.baseMapper.getNineDayPay(shouldPayVo.getUserId(),time3)==null?0:this.baseMapper.getNineDayPay(shouldPayVo.getUserId(),time3));
|
|
}
|
return list;
|
}
|
|
@Override
|
public List<ReceivablesList> listOfReceivables(Page<ReceivablesList> receivableVoPage, String time, String name, Integer invoicesId, Integer orderId, Integer state) {
|
String sTime=null;
|
String eTime =null;
|
if(Objects.nonNull(time)){
|
sTime = time.split(" - ")[0]+" 00:00:01";
|
eTime = time.split(" - ")[1]+" 23:59:59";
|
}
|
List<ReceivablesList> receivablesLists = this.baseMapper.listOfReceivables(receivableVoPage, sTime, eTime, name, invoicesId, orderId, state);
|
for (ReceivablesList receivablesList : receivablesLists) {
|
Integer id= this.baseMapper.getPayStatus(receivablesList.getOrderId());
|
if(id==null){
|
receivablesList.setPayStatus(1);
|
}else {
|
receivablesList.setPayStatus(2);
|
}
|
}
|
return receivablesLists;
|
}
|
|
@Override
|
public List<PayList> listOfPay(Page<PayList> receivableVoPage, String time, String name, Integer billId, Integer orderId, Integer state) {
|
String sTime=null;
|
String eTime =null;
|
if(Objects.nonNull(time)){
|
sTime = time.split(" - ")[0]+" 00:00:01";
|
eTime = time.split(" - ")[1]+" 23:59:59";
|
}
|
List<PayList> list = this.baseMapper.listOfPay(receivableVoPage, sTime, eTime, name, billId, orderId, state);
|
return list;
|
}
|
|
@Override
|
public InvoicesCarVo listOPayInfo(Long number) {
|
InvoicesVo info1 = tUserMapper.getOrderInfo(number);
|
InvoicesCarVo info = new InvoicesCarVo();
|
BeanUtil.copyProperties(info1,info);
|
|
// 根据订单id 获取货物信息
|
Long id = info.getId();
|
TOrder tOrder = this.baseMapper.selectById(id);
|
|
List<TGoods> orders = tGoodsMapper.selectList(new EntityWrapper<TGoods>().eq("order_id", id));
|
ArrayList<TGoodsVo> tGoodsVos = new ArrayList<>();
|
TCompany tCompany = tCompanyMapper.selectById(info.getCompanyId());
|
List<TBoxSize> tBoxSizes = sizeService.selectList(null);
|
|
for (TGoods order : orders) {
|
TGoodsVo tGoodsVo = new TGoodsVo();
|
tGoodsVo.setName(tCompany.getName());
|
tGoodsVo.setSize(order.getSize());
|
tGoodsVo.setKg(order.getKg());
|
String size = order.getSize();
|
for (TBoxSize tBoxSize : tBoxSizes) {
|
if(size.equals(tBoxSize.getBoxName())){
|
tGoodsVo.setLength(tBoxSize.getBoxLength());
|
tGoodsVo.setWidth(tBoxSize.getBoxWidth());
|
tGoodsVo.setHeight(tBoxSize.getBoxHigh());
|
}
|
}
|
tGoodsVos.add(tGoodsVo);
|
}
|
// 付卡车公司钱
|
BigDecimal payMoney = tOrder.getPayMoney();
|
Integer carriersId = tOrder.getCarriersId();
|
TCarriers tCarriers = carriersMapper.selectById(carriersId);
|
Double commission = tCarriers.getCommission();
|
BigDecimal multiply = new BigDecimal(commission).multiply(new BigDecimal(0.01));
|
BigDecimal multiply1 = payMoney.multiply(multiply);
|
info.setGoodsVos(tGoodsVos);
|
info.setAmount(multiply1.doubleValue());
|
return info;
|
}
|
|
@Override
|
public Boolean confirmationOfPayment(Long number, int type, String remark) {
|
Boolean b =false;
|
// 同意
|
if(type==1){
|
b = this.baseMapper.agreePay(number);
|
}else {
|
b = this.baseMapper.noAgreePay(number,remark);
|
}
|
|
return b;
|
}
|
|
@Override
|
public Boolean agreeOfPayment(Long number) {
|
return this.baseMapper.agreeOfPayment(number);
|
}
|
|
@Resource
|
private TDriverMapper driverMapper;
|
|
@Resource
|
private TPowerUnitsMapper powerUnitsMapper;
|
|
@Override
|
public IndexInfo indexList(String time) {
|
IndexInfo indexInfo = new IndexInfo();
|
// 卡车公司收入时间
|
String sTime=null;
|
String eTime=null;
|
if(ToolUtil.isNotEmpty(time)){
|
sTime=time.split(" - ")[0]+" 00:00:01";
|
eTime=time.split(" - ")[1]+" 23:59:59";
|
}
|
Integer companyId = UserInfoUtil.getId();
|
// 获取卡车公司收入
|
Double companyIncome = this.baseMapper.getCompanyIncome(companyId, sTime, eTime);
|
|
indexInfo.setAccountsReceivable(new BigDecimal(companyIncome));
|
// 获取卡车公司支出-》 是否存在承运商 -》算价格
|
EntityWrapper<TOrder> wrapper = new EntityWrapper<>();
|
wrapper.eq("company_id",companyId);
|
wrapper.eq("carriers_pay_status",1);
|
if(sTime!=null){
|
wrapper.between("success_time",sTime,eTime);
|
}
|
List<TOrder> orders = this.baseMapper.selectList(wrapper);
|
// 找出有承运商的订单
|
List<TOrder> collect = orders.stream().filter(o -> ToolUtil.isNotEmpty(o.getCarriersId())).collect(Collectors.toList());
|
// 付给承运商的钱
|
BigDecimal disburse = new BigDecimal(BigInteger.ZERO);
|
for (TOrder tOrder : collect) {
|
TCarriers tCarriers = carriersMapper.selectById(tOrder.getCarriersId());
|
Double commission = tCarriers.getCommission();
|
BigDecimal payMoney = tOrder.getPayMoney();
|
if(ToolUtil.isNotEmpty(commission)){
|
BigDecimal bigDecimal = new BigDecimal(commission);
|
BigDecimal multiply = payMoney.multiply(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
|
disburse = disburse.add(multiply);
|
}
|
}
|
indexInfo.setAccountsPayable(disburse);
|
indexInfo.setPlatformRevenue(indexInfo.getAccountsReceivable().subtract(indexInfo.getAccountsPayable()));
|
// 所有的信息
|
// 所有司机
|
Integer integer = driverMapper.selectCount(new EntityWrapper<TDriver>().eq("company_id", companyId).eq("remove",0));
|
indexInfo.setDriver(integer);
|
//车头
|
Integer integer1 = powerUnitsMapper.selectCount(new EntityWrapper<TPowerUnits>().eq("company_id", companyId).eq("type", 1));
|
indexInfo.setPowerUnits(integer1);
|
// 车架
|
indexInfo.setChassises(powerUnitsMapper.selectCount(new EntityWrapper<TPowerUnits>().eq("company_id", companyId).eq("type", 2)));
|
// 总订单
|
indexInfo.setOrdersTotal(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",companyId)));
|
//
|
indexInfo.setInTransit(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",companyId).eq("status","7")));
|
indexInfo.setDispatching(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",companyId).eq("status","0")));
|
indexInfo.setCanceled(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",companyId).eq("status","16")));
|
indexInfo.setCompleted(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",companyId).eq("status","1")));
|
//获取当前公司的订单数量 根据当前月推算前12个月
|
ArrayList<IndexMonth> indexMonths = new ArrayList<>();
|
//获取当前月份
|
|
Calendar instance = Calendar.getInstance();
|
instance.setTime(new Date());
|
for (int i = 0; i <12; i++) {
|
if(i==0){
|
IndexMonth indexMonth = new IndexMonth();
|
int month = DateUtil.thisMonth();
|
indexMonth.setMonth(month);
|
indexMonth.setOrderNumber(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",companyId).between("pay_time",DateUtil.beginOfMonth(new Date()),DateUtil.endOfMonth(new Date()))));
|
indexMonths.add(indexMonth);
|
}else {
|
IndexMonth indexMonth = new IndexMonth();
|
instance.add(Calendar.MONTH, -1);
|
Date time1 = instance.getTime();
|
int month = DateUtil.month(time1);
|
indexMonth.setMonth(month);
|
indexMonth.setOrderNumber(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",companyId).between("pay_time",DateUtil.beginOfMonth(time1),DateUtil.endOfMonth(time1))));
|
indexMonths.add(indexMonth);
|
}
|
}
|
indexInfo.setList(indexMonths);
|
return indexInfo;
|
}
|
|
|
|
|
@Override
|
public InvoicesVoTwo listOfReceivablesInfo(Long orderId) {
|
InvoicesVoTwo invoicesVoTwo = new InvoicesVoTwo();
|
TOrder tOrder = this.baseMapper.selectById(orderId);
|
invoicesVoTwo.setId(tOrder.getId());
|
invoicesVoTwo.setPickupDate(tOrder.getShipmentDate());
|
invoicesVoTwo.setDeliveryDate(tOrder.getDeliveryDate());
|
invoicesVoTwo.setInvoiceNumber(tOrder.getInvoiceNumber());
|
invoicesVoTwo.setRemark(tOrder.getRemark());
|
// 根据订单id 获取价格
|
List<TPrice> prices = priceMapper.selectList(new EntityWrapper<TPrice>().eq("order_id", tOrder.getId()));
|
ArrayList<TPriceVo> priceVos = new ArrayList<TPriceVo>();
|
for (TPrice price : prices) {
|
TPriceVo tPriceVo = new TPriceVo();
|
tPriceVo.setId(price.getId());
|
tPriceVo.setPrice(price.getCarPrice());
|
tPriceVo.setType(price.getType());
|
priceVos.add(tPriceVo);
|
}
|
invoicesVoTwo.setPriceVos(priceVos);
|
|
return invoicesVoTwo;
|
}
|
@Override
|
public InvoicesVoOne listOfReceivablesInfoOne(Long orderId) {
|
InvoicesVoOne info = tUserMapper.getOrderInfoOne(orderId);
|
// 根据订单id 获取货物信息
|
Long id = info.getId();
|
|
TOrder tOrder = this.baseMapper.selectById(id);
|
List<TGoods> orders = tGoodsMapper.selectList(new EntityWrapper<TGoods>().eq("order_id", id));
|
ArrayList<TGoodsVo> tGoodsVos = new ArrayList<>();
|
TCompany tCompany = tCompanyMapper.selectById(info.getCompanyId());
|
List<TBoxSize> tBoxSizes = sizeService.selectList(null);
|
for (TGoods order : orders) {
|
TGoodsVo tGoodsVo = new TGoodsVo();
|
tGoodsVo.setName(tCompany.getName());
|
tGoodsVo.setSize(order.getSize());
|
tGoodsVo.setKg(order.getKg());
|
String size = order.getSize();
|
for (TBoxSize tBoxSize : tBoxSizes) {
|
if(size.equals(tBoxSize.getBoxName())){
|
tGoodsVo.setLength(tBoxSize.getBoxLength());
|
tGoodsVo.setWidth(tBoxSize.getBoxWidth());
|
tGoodsVo.setHeight(tBoxSize.getBoxHigh());
|
}
|
}
|
tGoodsVos.add(tGoodsVo);
|
}
|
|
// 根据订单id 获取价格
|
List<TPrice> prices = priceMapper.selectList(new EntityWrapper<TPrice>().eq("order_id", tOrder.getId()));
|
|
ArrayList<TPriceVo> priceVos = new ArrayList<TPriceVo>();
|
for (TPrice price : prices) {
|
TPriceVo tPriceVo = new TPriceVo();
|
tPriceVo.setId(price.getId());
|
tPriceVo.setPrice(price.getCarPrice());
|
tPriceVo.setType(price.getType());
|
priceVos.add(tPriceVo);
|
}
|
info.setGoodsVos(tGoodsVos);
|
info.setPriceVos(priceVos);
|
|
|
|
return info;
|
}
|
|
|
|
|
@Override
|
public List<OrderListVo> getOrderList(Page<OrderListVo> orderListVoPage, OrderListDto dto) {
|
String sTime =null;
|
String eTime = null;
|
if(ToolUtil.isNotEmpty(dto.getDateRange())){
|
String[] split = dto.getDateRange().split(" - ");
|
sTime=split[0]+" 00:00:01";
|
eTime=split[1]+" 23:59:59";
|
}
|
Integer id = UserInfoUtil.getId();
|
List<OrderListVo> list = this.baseMapper.getOrderListOne(orderListVoPage,sTime,eTime,dto.getCustomerName(),dto.getId(),dto.getGroupId(),dto.getSaleId(),dto.getState(),id,dto.getType());
|
for (OrderListVo orderListVo : list) {
|
// TODO 对接第三方 看是否能提柜
|
if(Objects.nonNull(dto.getState())){
|
if(dto.getState()==1){
|
|
}else {
|
|
}
|
}
|
}
|
return list;
|
}
|
|
@Override
|
public List<GoodsInfoVo> getGoodsInfo(Long orderId) {
|
TOrder tOrder = this.baseMapper.selectById(orderId);
|
ArrayList<GoodsInfoVo> goodsInfoVos = new ArrayList<>();
|
List<TGoods> goods = tGoodsMapper.selectList(new EntityWrapper<TGoods>().eq("order_id", orderId));
|
for (TGoods g : goods) {
|
GoodsInfoVo goodsInfoVo = new GoodsInfoVo();
|
goodsInfoVo.setAwbNo(g.getBillNumber());
|
goodsInfoVo.setContainer(g.getContainerNumber());
|
goodsInfoVo.setHazmat(g.getDanger());
|
goodsInfoVo.setOverWeight(g.getWeight());
|
goodsInfoVo.setShippingLine(g.getShippingLine());
|
goodsInfoVo.setSize(g.getSize());
|
goodsInfoVo.setType(g.getType());
|
goodsInfoVo.setTypeClass(g.getTypeClass());
|
goodsInfoVo.setWeight(g.getKg());
|
goodsInfoVos.add(goodsInfoVo);
|
}
|
return goodsInfoVos;
|
}
|
|
@Override
|
public OrderInfo getOrderInfo(Long orderId) {
|
OrderInfo orderInfo = new OrderInfo();
|
ArrayList<LonLat> lonLats = new ArrayList<>();
|
|
TOrder tOrder = this.baseMapper.selectById(orderId);
|
orderInfo.setSlat(tOrder.getStartLat());
|
orderInfo.setSlon(tOrder.getStartLon());
|
LonLat lonLat = new LonLat();
|
lonLat.setLat(tOrder.getStartLat());
|
lonLat.setLng(tOrder.getStartLon());
|
lonLats.add(lonLat);
|
String s = tOrder.geteAddress();
|
// GeocodeVo geocode = googleMapUtil.getGeocode(s);
|
// orderInfo.setElat(String.valueOf(geocode.getLat()));
|
// orderInfo.setElon(String.valueOf(geocode.getLng()));
|
lonLat=new LonLat();
|
lonLat.setLng("-113.066919618184");
|
lonLat.setLat("37.684389618184");
|
lonLats.add(lonLat);
|
orderInfo.setElat("37.684389618184");
|
orderInfo.setElon("-113.066919618184");
|
|
orderInfo.setLonLats(lonLats);
|
Long quoteId = tQuoteMapper.selectList(new EntityWrapper<TQuote>().eq("order_id", tOrder.geteZipZ())).get(0).getId();
|
orderInfo.setType(tOrder.getType());
|
orderInfo.setQuoteId(quoteId);
|
// 获取用户
|
Integer userId = tOrder.getUserId();
|
TUser tUser = tUserMapper.selectById(userId);
|
orderInfo.setCustomer(tUser.getCompanyName());
|
// 获取组
|
Integer groupId = tUser.getGroupId();
|
if(groupId!=null) {
|
TGroup tGroup = tGroupMapper.selectById(groupId);
|
orderInfo.setSalesGroup(tGroup.getName());
|
Integer salesId = tGroup.getSalesId();
|
User user = userMapper.selectById(salesId);
|
orderInfo.setSales(user.getName());
|
}
|
// 获取码头id 获取码头地址 pickup信息
|
Integer portId = tOrder.getPort();
|
TPort tPort = portMapper.selectById(portId);
|
orderInfo.setAddress(tOrder.geteAddress());
|
orderInfo.setContactName(tOrder.getsName());
|
orderInfo.setContactPhone(tOrder.getsPhone());
|
orderInfo.setContactEmail(tOrder.getsEmail());
|
orderInfo.setShipmentDate(tOrder.getShipmentDate());
|
orderInfo.setResidentitalPickUp(tOrder.getAccessorialStr());
|
|
String warehouse = tOrder.getWarehouse();
|
// 是仓库
|
if(!"0".equals(warehouse)){
|
TWarehouse tWarehouse = wareHouseMapper.selectList(new EntityWrapper<TWarehouse>().eq("company_id", tOrder.getCompanyId()).eq("code", warehouse)).get(0);
|
orderInfo.setWareHouse(tWarehouse.getAddress());
|
}
|
// destination信息
|
orderInfo.setEndAddress(tOrder.geteAddress());
|
orderInfo.setECompanyName(tOrder.geteCompanyName());
|
orderInfo.setEContactName(tOrder.geteName());
|
orderInfo.setEContactPhone(tOrder.getePhone());
|
orderInfo.setEContactEmail(tOrder.geteEmail());
|
orderInfo.setDeliveryDate(tOrder.getDeliveryDate());
|
orderInfo.setDeliverStr(tOrder.getDeliveryStr());
|
orderInfo.setCarrierQuoteNumber(quoteId);
|
|
// 根据订单id获取货物
|
List<TGoods> goods = tGoodsMapper.selectList(new EntityWrapper<TGoods>().eq("order_id", orderId));
|
ArrayList<String> strings = new ArrayList<>();
|
goods.forEach(e->{
|
strings.add(e.getContainerNumber());
|
orderInfo.setBl(e.getBillNumber());
|
});
|
orderInfo.setContainer(strings);
|
ArrayList<DriverNoteVo> driverNoteVos = new ArrayList<>();
|
ArrayList<DriverNoteVo> driverNoteVos1 = new ArrayList<>();
|
|
// 获取司机note 和 trouble
|
List<DriverNote> driverNotes = driverNoteMapper.selectList(new EntityWrapper<DriverNote>().eq("order_id", orderId));
|
for (DriverNote driverNote : driverNotes) {
|
DriverNoteVo driverNoteVo = new DriverNoteVo();
|
BeanUtil.copyProperties(driverNote,driverNoteVo);
|
TDriver tDriver = driverService.selectById(driverNoteVo.getDriverId());
|
driverNoteVo.setDriverName(tDriver.getDriverName());
|
if(driverNoteVo.getType()==1){
|
driverNoteVos.add(driverNoteVo);
|
}else {
|
driverNoteVos1.add(driverNoteVo);
|
}
|
}
|
orderInfo.setNote(driverNoteVos);
|
orderInfo.setTrouble(driverNoteVos1);
|
orderInfo.setState(tOrder.getState());
|
return orderInfo;
|
|
|
}
|
|
@Override
|
public Boolean addOrderFile(Long orderId, String url, String name) {
|
return this.baseMapper.addOrderFile(orderId,url,name);
|
}
|
|
@Override
|
public List<OrderInfoVo> getOrderListIndex(Page<OrderInfoVo> orderInfoVoPage, int id, String containerNo, String sTime, String eTime,int type) {
|
List<OrderInfoVo> orderListIndex = this.baseMapper.getOrderListIndex(orderInfoVoPage, id, containerNo, sTime, eTime,type);
|
for (OrderInfoVo listIndex : orderListIndex) {
|
if(listIndex.getStatus()==6&&listIndex.getSendType().equals("Live Unload")){
|
TTransportation tTransportation = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", listIndex.getOrderId()).eq("type", 4));
|
if(tTransportation!=null){
|
Integer portId = tTransportation.getPortId();
|
TPort tPort = portMapper.selectById(portId);
|
listIndex.setPortName(tPort.getName());
|
listIndex.setReturnTime(tTransportation.getReturnDate());
|
}
|
|
}
|
}
|
return orderListIndex;
|
}
|
|
|
@Resource
|
private TTransportationService tTransportationService;
|
|
@Resource
|
private ITExamSiteService examSiteService;
|
|
@Resource
|
private TYardService yardService;
|
@Override
|
public OrderDetailVo orderInfo(Long id,int typeStr) {
|
OrderDetailVo orderDetailVo = new OrderDetailVo();
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
// 获取经纬度
|
TOrder tOrder = this.baseMapper.selectById(id);
|
if(tOrder.getExamSite()!=null && tOrder.getType().equals("Live Unload")){
|
if(tOrder.getStatus().equals("0")){
|
orderDetailVo.setNextStatus("2");
|
}else
|
if(tOrder.getStatus().equals("2")){
|
orderDetailVo.setNextStatus("3");
|
}else
|
if(tOrder.getStatus().equals("3")){
|
orderDetailVo.setNextStatus("4");
|
}else
|
if(tOrder.getStatus().equals("4")){
|
orderDetailVo.setNextStatus("12");
|
}else
|
if(tOrder.getStatus().equals("12")){
|
orderDetailVo.setNextStatus("13");
|
}else
|
if(tOrder.getStatus().equals("13")){
|
orderDetailVo.setNextStatus("14");
|
}else
|
if(tOrder.getStatus().equals("14")){
|
orderDetailVo.setNextStatus("5");
|
}else
|
if(tOrder.getStatus().equals("5")){
|
orderDetailVo.setNextStatus("6");
|
}else
|
if(tOrder.getStatus().equals("6")){
|
orderDetailVo.setNextStatus("7");
|
}else
|
if(tOrder.getStatus().equals("7")){
|
orderDetailVo.setNextStatus("8");
|
}else
|
if(tOrder.getStatus().equals("8")){
|
orderDetailVo.setNextStatus("9");
|
}else
|
if(tOrder.getStatus().equals("9")){
|
orderDetailVo.setNextStatus("10");
|
}else
|
if(tOrder.getStatus().equals("10")){
|
orderDetailVo.setNextStatus("11");
|
}else
|
if(tOrder.getStatus().equals("11")){
|
orderDetailVo.setNextStatus("18");
|
}
|
}else if(tOrder.getExamSite()==null && tOrder.getType().equals("Live Unload")){
|
if(tOrder.getStatus().equals("0")){
|
orderDetailVo.setNextStatus("2");
|
}else
|
if(tOrder.getStatus().equals("2")){
|
orderDetailVo.setNextStatus("3");
|
}else
|
if(tOrder.getStatus().equals("3")){
|
orderDetailVo.setNextStatus("4");
|
}else
|
if(tOrder.getStatus().equals("4")){
|
orderDetailVo.setNextStatus("5");
|
}else
|
if(tOrder.getStatus().equals("5")){
|
orderDetailVo.setNextStatus("6");
|
}else
|
if(tOrder.getStatus().equals("6")){
|
orderDetailVo.setNextStatus("7");
|
}else
|
if(tOrder.getStatus().equals("7")){
|
orderDetailVo.setNextStatus("8");
|
}else
|
if(tOrder.getStatus().equals("8")){
|
orderDetailVo.setNextStatus("9");
|
}else
|
if(tOrder.getStatus().equals("9")){
|
orderDetailVo.setNextStatus("10");
|
}else
|
if(tOrder.getStatus().equals("10")){
|
orderDetailVo.setNextStatus("11");
|
}else
|
if(tOrder.getStatus().equals("11")){
|
orderDetailVo.setNextStatus("18");
|
}
|
}else if(tOrder.getExamSite()!=null && !tOrder.getType().equals("Live Unload")){
|
if(tOrder.getStatus().equals("0")){
|
orderDetailVo.setNextStatus("2");
|
}else
|
if(tOrder.getStatus().equals("2")){
|
orderDetailVo.setNextStatus("3");
|
}else
|
if(tOrder.getStatus().equals("3")){
|
orderDetailVo.setNextStatus("4");
|
}else
|
if(tOrder.getStatus().equals("4")){
|
orderDetailVo.setNextStatus("12");
|
}else
|
if(tOrder.getStatus().equals("12")){
|
orderDetailVo.setNextStatus("13");
|
}else
|
if(tOrder.getStatus().equals("13")){
|
orderDetailVo.setNextStatus("14");
|
}else
|
if(tOrder.getStatus().equals("14")){
|
orderDetailVo.setNextStatus("5");
|
}else
|
if(tOrder.getStatus().equals("5")){
|
orderDetailVo.setNextStatus("6");
|
}else
|
if(tOrder.getStatus().equals("6")){
|
orderDetailVo.setNextStatus("7");
|
}else
|
if(tOrder.getStatus().equals("7")){
|
orderDetailVo.setNextStatus("8");
|
}else
|
if(tOrder.getStatus().equals("8")){
|
orderDetailVo.setNextStatus("9");
|
}
|
}else {
|
if(tOrder.getStatus().equals("0")){
|
orderDetailVo.setNextStatus("2");
|
}else
|
if(tOrder.getStatus().equals("2")){
|
orderDetailVo.setNextStatus("3");
|
}else
|
if(tOrder.getStatus().equals("3")){
|
orderDetailVo.setNextStatus("4");
|
}else
|
if(tOrder.getStatus().equals("4")){
|
orderDetailVo.setNextStatus("5");
|
}else
|
if(tOrder.getStatus().equals("5")){
|
orderDetailVo.setNextStatus("6");
|
}else
|
if(tOrder.getStatus().equals("6")){
|
orderDetailVo.setNextStatus("7");
|
}else
|
if(tOrder.getStatus().equals("7")){
|
orderDetailVo.setNextStatus("8");
|
}else
|
if(tOrder.getStatus().equals("8")){
|
orderDetailVo.setNextStatus("9");
|
}
|
}
|
String startLat = tOrder.getStartLat();
|
String startLon = tOrder.getStartLon();
|
orderDetailVo.setLat(startLat);
|
orderDetailVo.setLon(startLon);
|
String s = tOrder.geteAddress();
|
try {
|
// FindPlaceFromTextVo findplacefromtext = googleMapUtil.findplacefromtext(s);
|
// Double lat = findplacefromtext.getLat();
|
// Double lng = findplacefromtext.getLng();
|
// orderDetailVo.setELat(lat.toString());
|
// orderDetailVo.setELon(lng.toString());
|
orderDetailVo.setELat("0");
|
orderDetailVo.setELon("0");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
String type = tOrder.getType();
|
TGoods tGoods = tGoodsMapper.selectList(new EntityWrapper<TGoods>().eq("order_id", id)).get(0);
|
orderDetailVo.setOrderType(type);
|
orderDetailVo.setContainerNumber(tGoods.getContainerNumber());
|
TTransportation tTransportations = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", id).eq("type",1));
|
// 第一个port
|
HashMap<String, Object> orderInfo = getOrderInfo(tTransportations, tOrder);
|
orderInfo.put("7_danger",tGoods.getDanger());
|
orderInfo.put("8_weight",tGoods.getWeight());
|
Map<String, Object> map = sortMapByKey(orderInfo);
|
if(typeStr==1){
|
maps.add(map);
|
}
|
if(tOrder.getExamSite()!=null){
|
Integer examSite = tOrder.getExamSite();
|
TExamSite tExamSite = examSiteService.selectById(examSite);
|
// 第二个检查站
|
Map<String, Object> examInfo = getExamInfo(tExamSite);
|
if(typeStr==1){
|
maps.add(examInfo);
|
}
|
}
|
TTransportation tTransportations1 = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", id).eq("type",2));
|
Integer yardId = tTransportations1.getYardId();
|
TYard tYard = yardService.selectById(yardId);
|
// 第三个 yard
|
Map<String, Object> yardOne = getYardOne(tTransportations1, tYard);
|
// 第四个 destination
|
Map<String, Object> destination = getDestination(tOrder);
|
if(typeStr==2){
|
maps.add(yardOne);
|
maps.add(destination);
|
}
|
TTransportation tTransportations2 = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", id).eq("type",3));
|
if(tTransportations2!=null){
|
TYard tYard1 = yardService.selectById(tTransportations2.getYardId());
|
// 第五个 yard
|
Map<String, Object> yardOne1 = getYardOne(tTransportations2, tYard1);
|
if(typeStr==3 && tOrder.getType().equals("Live Unload")){
|
maps.add(yardOne1);
|
}
|
}
|
|
TTransportation tTransportations3 = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", id).eq("type",4));
|
if(tTransportations3!=null){
|
TPort tPort = portMapper.selectById(tTransportations3.getPortId());
|
|
// 第六个 port
|
Map<String, Object> port = getPort(tTransportations3, tPort);
|
if(typeStr==4 && tOrder.getType().equals("Live Unload")){
|
maps.add(port);
|
}
|
}
|
orderDetailVo.setTGoods(tGoods);
|
orderDetailVo.setOrderId(id);
|
orderDetailVo.setStatus(tOrder.getStatus());
|
orderDetailVo.setList(maps);
|
return orderDetailVo;
|
}
|
|
private HashMap<String, Object> getOrderInfo(TTransportation tTransportation,TOrder tOrder){
|
HashMap<String, Object> map = new HashMap<>();
|
String name = tTransportation.getName();
|
String phone = tTransportation.getPhone();
|
String email = tTransportation.getEmail();
|
Date shipmentDate = tOrder.getShipmentDate();
|
Date pickupTimeTruck = tOrder.getPickupTimeTruck();
|
map.put("1_title","Port");
|
map.put("2_contactName",name);
|
map.put("3_contactPhone",phone);
|
map.put("4_contactEmail",email);
|
map.put("5_shipmentEta",shipmentDate);
|
map.put("6_pickupDate",pickupTimeTruck);
|
return map;
|
}
|
|
private Map<String, Object> getPort(TTransportation tTransportation,TPort tPort){
|
HashMap<String, Object> map = new HashMap<>();
|
String address = tPort.getAddress();
|
Integer city = tPort.getCity();
|
TCountry cityInfo = countryService.selectById(city);
|
TCountry state = countryService.selectById(cityInfo.getParentId());
|
TCountry tCountry = countryService.selectById(state.getParentId());
|
map.put("1_title","Port");
|
map.put("2_address",address+cityInfo.getName()+state.getName()+tPort.getZipCode()+tCountry.getName());
|
map.put("3_portName",tPort.getName());
|
map.put("4_contactName",tTransportation.getName());
|
map.put("5_contactPhone",tTransportation.getPhone());
|
map.put("6_contactEmail",tTransportation.getEmail());
|
map.put("7_returnTimeToPort",tTransportation.getReturnDate());
|
Map<String, Object> map1 = sortMapByKey(map);
|
return map1;
|
}
|
|
@Resource
|
private ITCountryService countryService;
|
|
private Map<String, Object> getExamInfo(TExamSite tExamSite){
|
HashMap<String, Object> map = new HashMap<>();
|
String address = tExamSite.getAddress();
|
String cityName = countryService.selectById(tExamSite.getCity()).getName();
|
String stateName = countryService.selectById(tExamSite.getState()).getName();
|
String name = countryService.selectById(tExamSite.getCountry()).getName();
|
map.put("1_title","Exam Site");
|
map.put("2_address",address+cityName+stateName+tExamSite.getZipCode()+name);
|
map.put("3_examSiteName",tExamSite.getStateName());
|
map.put("4_contactName",tExamSite.getContactName());
|
map.put("5_contactPhone",tExamSite.getContactPhone());
|
map.put("6_contactEmail",tExamSite.getContactEmail());
|
Map<String, Object> map1 = sortMapByKey(map);
|
return map1;
|
}
|
|
|
private static Map<String, Object> sortMapByKey(Map<String, Object> map) {
|
if (map == null || map.isEmpty()) {
|
return null;
|
}
|
|
Map<String, Object> sortMap = new TreeMap<String, Object>(
|
new MapKeyComparator());
|
|
sortMap.putAll(map);
|
|
return sortMap;
|
}
|
|
static class MapKeyComparator implements Comparator<String>{
|
|
@Override
|
public int compare(String str1, String str2) {
|
|
return str1.compareTo(str2);
|
}
|
}
|
|
private Map<String, Object> getYardOne(TTransportation tTransportations1,TYard yard){
|
HashMap<String, Object> map = new HashMap<>();
|
// String cityName = countryService.selectById(yard.getCity()).getName();
|
// String stateName = countryService.selectById(yard.getState()).getName();
|
// String name = countryService.selectById(yard.getCountry()).getName();
|
map.put("1_title","Yard");
|
map.put("2_address",yard.getStreetAddress()+yard.getCity()+yard.getState()+yard.getZipCode()+yard.getCountry());
|
map.put("3_yardName",yard.getYardName());
|
map.put("4_contactName",tTransportations1.getName());
|
map.put("5_contactPhone",tTransportations1.getPhone());
|
map.put("6_contactEmail",tTransportations1.getEmail());
|
Map<String, Object> map1 = sortMapByKey(map);
|
return map1;
|
}
|
|
private Map<String, Object> getDestination(TOrder tOrder){
|
HashMap<String, Object> map = new HashMap<>();
|
TPort tPort = portMapper.selectById(tOrder.getPort());
|
String cityName = countryService.selectById(tPort.getCity()).getName();
|
TCountry tCountry = countryService.selectById(countryService.selectById(tPort.getCity()).getParentId());
|
String stateName = tCountry.getName();
|
String name = countryService.selectById(tCountry.getParentId()).getName();
|
map.put("1_title","Destination");
|
map.put("2_address",tOrder.geteAddress()+cityName+stateName+tOrder.geteZipCode()+name);
|
map.put("3_companyName",tOrder.geteCompanyName());
|
map.put("4_contactName",tOrder.geteName());
|
map.put("5_contactPhone",tOrder.getePhone());
|
map.put("6_contactEmail",tOrder.geteEmail());
|
// 1是亚马逊仓库
|
if("0".equals(tOrder.getWarehouse())){
|
map.put("8_isWarehouse",0);
|
}else {
|
map.put("8_isWarehouse",1);
|
}
|
map.put("9_delivery",tOrder.getDeliveryStr());
|
map.put("7_deliveryDate",tOrder.getDeliveryDate());
|
Map<String, Object> map1 = sortMapByKey(map);
|
return map1;
|
}
|
|
|
|
}
|