From 871efa21e6c95520e9825ae1f2338c9a919fdd5d Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期日, 15 十月 2023 17:57:48 +0800 Subject: [PATCH] 用户端代码 --- src/main/java/com/stylefeng/guns/modular/system/controller/OrderController.java | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 208 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/stylefeng/guns/modular/system/controller/OrderController.java b/src/main/java/com/stylefeng/guns/modular/system/controller/OrderController.java index f8854fb..0ee518e 100644 --- a/src/main/java/com/stylefeng/guns/modular/system/controller/OrderController.java +++ b/src/main/java/com/stylefeng/guns/modular/system/controller/OrderController.java @@ -3,10 +3,16 @@ import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; +import com.stylefeng.guns.core.util.ToolUtil; +import com.stylefeng.guns.modular.system.enums.FacilityCodeEnum; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; +import com.stylefeng.guns.modular.system.utils.PortUtil.FortyNineUtil; +import com.stylefeng.guns.modular.system.utils.PortUtil.SCACEnum; +import com.stylefeng.guns.modular.system.utils.PortUtil.TerminalInterfaceAcquisitionUtil; import com.stylefeng.guns.modular.system.utils.tips.ErrorTip; import com.stylefeng.guns.modular.system.utils.tips.SuccessTip; +import com.stylefeng.guns.modular.system.warpper.TerminaleDataWarpper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -21,10 +27,7 @@ import java.math.BigDecimal; import java.net.FileNameMap; import java.net.URLConnection; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; +import java.util.*; @Controller @Api(tags = "订单") @@ -110,6 +113,31 @@ return new SuccessTip(); } + /** + * company 订单 + * @param orderId 订单id + * @return + */ + @ApiOperation(value = "用户端-检查站可取货",notes="用户端-检查站可取货") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), + @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), + }) + @PostMapping(value = "/affirmOne") + @ResponseBody + public Object affirmOne( Long orderId) { + TOrder tOrder = orderService.selectById(orderId); + + if(tOrder.getStatus().equals("13")){ + tOrder.setStatus("14"); + }else { + return new ErrorTip(5010,"The current status cannot be modified"); + } + orderService.updateById(tOrder); + return new SuccessTip(); + } + + @ApiOperation(value = "支付",notes="支付") @ApiImplicitParams({ @@ -176,6 +204,24 @@ } + @ApiOperation(value = "用户端-安排检查站",notes="用户端-安排检查站") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), + @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), + @ApiImplicitParam(name = "examId", value = "examId", required = true, dataType = "int"), + }) + @GetMapping(value = "/examAdd") + @ResponseBody + public Object examAdd(Long orderId,int examId) { + TOrder tOrder = orderService.selectById(orderId); + tOrder.setExamSite(examId); + orderService.updateById(tOrder); + return new SuccessTip(); + } + + + + @ApiOperation(value = "商品详情",notes="商品详情") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @@ -213,10 +259,21 @@ @GetMapping(value = "/getOrderInfo") @ResponseBody public Object getOrderInfo( Long orderId) { - OrderInfo orderInfo = orderService.getOrderInfo(orderId); + HashMap<String, Object> orderInfo = orderService.getOrderInfo(orderId); return new SuccessTip(orderInfo); } - + @ApiOperation(value = "根据zipcode获取用户地址",notes="根据zipcode获取用户地址") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), + @ApiImplicitParam(name = "zipcode", value = "zipcode", required = true, dataType = "String"), + @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer"), + }) + @GetMapping(value = "/getAddressByCode") + @ResponseBody + public Object getAddressByCode( String zipcode,Integer id) { + List<TUserAddress> addresses = addressService.selectList(new EntityWrapper<TUserAddress>().eq("user_id", id).eq("zip_code", zipcode).eq("remove",0)); + return new SuccessTip(addresses); + } @ApiOperation(value = "订单详情--修改reference numbers",notes="订单详情--修改reference numbers") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @@ -245,6 +302,7 @@ ArrayList<OrderDriverInfo> orderDriverInfos = new ArrayList<>(); ArrayList<Integer> driverIds = new ArrayList<>(); TOrder tOrder = orderService.selectById(orderId); + TPort tPort = portService.selectById(tOrder.getPort()); // 第一个开始司机id Integer sDriverid = tOrder.getsDriverid(); if(sDriverid!=null){ @@ -263,17 +321,61 @@ if(driverIdOne!=null){ driverIds.add(driverIdOne); } - List<TTransportation> tTransportations = tTransportationService.selectList(new EntityWrapper<TTransportation>().eq("order_id", orderId).in("driver_id", driverIds)); + TGoods tGoods = goodsService.selectOne(new EntityWrapper<TGoods>().eq("order_id", tOrder.getId())); + List<TTransportation> tTransportations = tTransportationService.selectList(new EntityWrapper<TTransportation>().eq("order_id", orderId).in("driver_id", driverIds).orderBy("type")); + TerminaleDataWarpper terminalStatus=new TerminaleDataWarpper(); + try { + if("LBCT".equals(tPort.getName()) || "APM".equals(tPort.getName())){ + terminalStatus = TerminalInterfaceAcquisitionUtil.getTerminalStatus(tPort.getName(),tGoods.getContainerNumber(), FacilityCodeEnum.USLAX.getMsg()); + }else { + // 去查是否存了containerid + if(ToolUtil.isNotEmpty(tGoods.getShipmentId()) && !"0".equals(tGoods.getShipmentId())){ + terminalStatus = FortyNineUtil.getContainerNo(tGoods.getShipmentId(), tGoods.getContainerNumber()); + }else { + + String shippingLine = tGoods.getShippingLine(); + SCACEnum scacEnum = SCACEnum.fromCode(shippingLine); + String s; + if(ToolUtil.isEmpty(tGoods.getTrackingId()) || "0".equals(tGoods.getTrackingId())){ + s = FortyNineUtil.trackingRequest(tGoods.getBillNumber(), scacEnum.getDesc()); + if(ToolUtil.isEmpty(s)){ + s = FortyNineUtil.trackingList(tGoods.getBillNumber()); + } + tGoods.setTrackingId(s); + goodsService.updateById(tGoods); + }else { + s = tGoods.getTrackingId(); + } + String shipmentId = FortyNineUtil.getShipmentId(s); + if(ToolUtil.isNotEmpty(shipmentId)){ + tGoods.setShipmentId(shipmentId); + goodsService.updateById(tGoods); + }else { + tGoods.setShipmentId("0"); + tGoods.setTrackingId("0"); + goodsService.updateById(tGoods); + } + terminalStatus = FortyNineUtil.getContainerNo(shipmentId, tGoods.getContainerNumber()); + } + } + }catch (Exception e){ + e.printStackTrace(); + terminalStatus =new TerminaleDataWarpper(); + } for (TTransportation tDriver : tTransportations) { OrderDriverInfo orderDriverInfo = new OrderDriverInfo(); orderDriverInfo.setId(tDriver.getId()); - if(tDriver.getId().equals(sDriverIdOne)&&tDriver.getType()==2){ + orderDriverInfo.setDriverId(tDriver.getDriverId()); + if(tDriver.getDriverId().equals(sDriverIdOne)&&tDriver.getType()==1){ orderDriverInfo.setPickUp(tDriver.getPickDate()); } - if(tDriver.getId().equals(driverid) &&tDriver.getType()==3){ + if(tDriver.getDriverId().equals(sDriverIdOne)&&tDriver.getType()==2){ + orderDriverInfo.setPickUp(tDriver.getPickDate()); + } + if(tDriver.getDriverId().equals(driverid) &&tDriver.getType()==3){ orderDriverInfo.setEmptyDate(tDriver.getEmptyDate()); } - if(tDriver.getId().equals(driverIdOne) &&tDriver.getType()==4){ + if(tDriver.getDriverId().equals(driverIdOne) &&tDriver.getType()==4){ orderDriverInfo.setReturnDate(tDriver.getReturnDate()); } orderDriverInfo.setContactEmail(tDriver.getEmail()); @@ -283,7 +385,7 @@ orderDriverInfo.setChassiess(powerUnitsService.selectById(tDriver.getChassises())); // TODO 第三方 目前不知道对接那个 - orderDriverInfo.setAppointmentNumber(null); + orderDriverInfo.setAppointmentNumber(terminalStatus.getAppointmentNumber()); orderDriverInfos.add(orderDriverInfo); @@ -291,6 +393,16 @@ transportInfo.setTruckCompany(tOrder.getTruckCompany()); transportInfo.setPickupTime(tOrder.getPickupTimeTruck()); transportInfo.setStreetTurn(tOrder.getStreetTurn()); + + + transportInfo.setLineHold(terminalStatus.getLineHold()); + transportInfo.setCustomHold(terminalStatus.getCustomHold()); + transportInfo.setPierpass(terminalStatus.getPierpass()); + transportInfo.setCTF(terminalStatus.getCtf()); + transportInfo.setClosedArea(terminalStatus.getClosedArea()); + transportInfo.setLFD(terminalStatus.getLfd()); + transportInfo.setAvailable(terminalStatus.getAvailability()); + transportInfo.setList(orderDriverInfos); Integer examSite = tOrder.getExamSite(); if(Objects.nonNull(examSite)){ @@ -303,6 +415,23 @@ } return new SuccessTip(transportInfo); } + + + @ApiOperation(value = "获取订单司机位置",notes="获取订单司机位置") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), + @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), + @ApiImplicitParam(name = "lon", value = "lon", required = true, dataType = "String"), + @ApiImplicitParam(name = "lat", value = "lat", required = true, dataType = "String"), + }) + @GetMapping(value = "/getLonLat") + @ResponseBody + public Object getLonLat(Long orderId){ + // 通过司机id获取订单 + List<Map<String,Object>> orders = orderService.getLonLat(orderId); + return new SuccessTip(orders); + } + @ApiOperation(value = "获取费用明细",notes="获取费用明细") @ApiImplicitParams({ @@ -319,7 +448,7 @@ TUser tUser = itUserService.selectById(userId); List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", tOrder.getId())); ArrayList<PriceInfo> priceInfos = new ArrayList<>(); - if(tUser.getGroupId()!=null){ + if(false){ TGroup tGroup = groupService.selectById(tUser.getGroupId()); User user = service.selectById(tGroup.getSalesId()); @@ -340,13 +469,7 @@ double v = ((double) tUserFeeSetting.getFee()) / 100; BigDecimal multiply = price.getPrice().multiply(new BigDecimal(v)); BigDecimal subtract = price.getPrice().subtract(multiply); - priceInfo.setCarrierCost(subtract); - priceInfo.setSalesProfit(new BigDecimal(commission)); - priceInfo.setMargin(multiply); }else { - priceInfo.setMargin(new BigDecimal(0)); - priceInfo.setSalesProfit(new BigDecimal(commission)); - priceInfo.setCarrierCost(price.getPrice()); } priceInfos.add(priceInfo); break; @@ -356,11 +479,8 @@ }else { for (TPrice price : prices) { PriceInfo priceInfo = new PriceInfo(); - priceInfo.setCarrierCost(price.getPrice()); priceInfo.setCustomerCost(price.getPrice()); priceInfo.setName(price.getType()); - priceInfo.setSalesProfit(new BigDecimal(0)); - priceInfo.setMargin(new BigDecimal(0)); priceInfos.add(priceInfo); } } @@ -451,7 +571,6 @@ return new ErrorTip(500,"ERROR"); } - @ApiOperation(value = "卡车公司--修改安排司机(单个)",notes="卡车公司--修改安排司机(单个)") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @@ -465,18 +584,19 @@ // 找出这个订单 TOrder tOrder = orderService.selectById(orderId); TTransportation list = companySelectDriverSingleDto.getList(); - Integer type = companySelectDriverSingleDto.getType(); + list.setOrderId(companySelectDriverSingleDto.getOrderId()); + Integer type = companySelectDriverSingleDto.getList().getType(); if(type==1){ - tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverid())); + tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverid()).eq("type",1)); tOrder.setsDriverid(list.getDriverId()); }else if(type==2){ - tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverIdOne())); + tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverIdOne()).eq("type",2)); tOrder.setsDriverIdOne(list.getDriverId()); }else if(type==3){ - tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverid())); + tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverid()).eq("type",3)); tOrder.seteDriverid(list.getDriverId()); }else { - tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverIdOne())); + tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverIdOne()).eq("type",4)); tOrder.seteDriverIdOne(list.getDriverId()); } tTransportationService.insert(list); @@ -489,7 +609,6 @@ } return new ErrorTip(500,"ERROR"); } - @Resource private TYardService yardService; @@ -591,6 +710,9 @@ return new SuccessTip(page); } + + + @ApiOperation(value = "获取订单文件",notes="获取订单文件") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @@ -615,7 +737,20 @@ } record.setType(type); } - orderFilePage.setRecords(records); + TOrder tOrder = orderService.selectById(orderId); + if(true){ + ArrayList<TOrderFile> tOrderFiles = new ArrayList<>(); + TOrderFile tOrderFile = new TOrderFile(); + tOrderFile.setName("Bill of lading.pdf"); + tOrderFile.setId(0); + tOrderFile.setType("file"); + tOrderFiles.add(tOrderFile); + tOrderFiles.addAll(records); + orderFilePage.setRecords(tOrderFiles); + }else { + + orderFilePage.setRecords(records); + } return new SuccessTip(orderFilePage); } @@ -654,6 +789,8 @@ try { OrderLading orderLading = new OrderLading(); TOrder tOrder = orderService.selectById(orderId); + + orderLading.setOrderId(tOrder.getId()); // 找出用户 TUser tUser = itUserService.selectById(tOrder.getUserId()); orderLading.setCustomerName(tUser.getCompanyName()); @@ -682,6 +819,48 @@ orderLading.setPo(tGoods.getPo()); orderLading.setCustRef(tGoods.getCustRef()); orderLading.setEntry(tGoods.getEntry()); + orderLading.setLbNo(tGoods.getBillNumber()); + String time =""; + if(ToolUtil.isNotEmpty(tGoods.getShipmentId()) && !"0".equals(tGoods.getShipmentId())){ + time= FortyNineUtil.getContainerNoOne(tGoods.getShipmentId(), tGoods.getContainerNumber()); + }else { + String shippingLine = tGoods.getShippingLine(); + SCACEnum scacEnum = SCACEnum.fromCode(shippingLine); + String s; + if(ToolUtil.isEmpty(tGoods.getTrackingId()) || "0".equals(tGoods.getTrackingId())){ + s = FortyNineUtil.trackingRequest(tGoods.getBillNumber(), scacEnum.getDesc()); + if(ToolUtil.isEmpty(s)){ + s = FortyNineUtil.trackingList(tGoods.getBillNumber()); + } + tGoods.setTrackingId(s); + goodsService.updateById(tGoods); + }else { + s = tGoods.getTrackingId(); + } + String shipmentId = FortyNineUtil.getShipmentId(s); + if(ToolUtil.isNotEmpty(shipmentId)){ + tGoods.setShipmentId(shipmentId); + goodsService.updateById(tGoods); + }else { + tGoods.setShipmentId("0"); + tGoods.setTrackingId("0"); + goodsService.updateById(tGoods); + } + time = FortyNineUtil.getContainerNoOne(shipmentId, tGoods.getContainerNumber()); + } + + orderLading.setEta(time); + String billNumber = tGoods.getBillNumber(); + List<TGoods> goods = goodsService.selectList(new EntityWrapper<TGoods>().eq("bill_number", billNumber)); + ArrayList<Map<String, String>> maps = new ArrayList<>(); + for (TGoods good : goods) { + HashMap<String, String> map = new HashMap<>(); + map.put("containerNo",good.getContainerNumber()); + map.put("size",good.getSize()); + map.put("weight",good.getKg()); + maps.add(map); + } + orderLading.setGoodsInfo(maps); // 获取收货信息 orderLading.setEndCompanyName(tOrder.geteCompanyName()); orderLading.setEndCompanyAddress(tOrder.geteAddress()); -- Gitblit v1.7.1