提交 7fe1dbd9 authored 作者: aiqingguo's avatar aiqingguo

运单统计

上级 9a617c3b
package com.clx.performance.controller.pc.child.carrier;
import com.clx.performance.service.child.CarrierOrderChildService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping(value="/pc/carrier/orderChild/")
@Validated
@Api(tags = "承运PC-运单")
@AllArgsConstructor
public class CarrierOrderChildController {
private final CarrierOrderChildService carrierOrderChildService;
}
package com.clx.performance.controller.temp;
import com.clx.performance.service.TempService;
import com.clx.performance.service.child.CarrierOrderChildService;
import com.msl.common.result.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -9,6 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
/**
* @Author: aiqingguo
......@@ -23,13 +26,18 @@ public class TempController {
@Autowired
private TempService tempService;
@Autowired
private CarrierOrderChildService carrierOrderChildService;
@ApiOperation(value = "test", notes = "<br>By:艾庆国")
@RequestMapping(value = "/test", method = RequestMethod.GET)
public Result<Void> test() {
return Result.ok();
public Result<HashMap> test(Integer sendAddressId, Integer receiveAddressId) {
carrierOrderChildService.getLineStatistics(sendAddressId, sendAddressId);
return Result.ok(carrierOrderChildService.getLineStatistics(sendAddressId, sendAddressId));
}
@ApiOperation(value = "更新网运标识", notes = "<br>By:艾庆国")
......
......@@ -16,6 +16,7 @@ import com.msl.common.base.Optional;
import com.msl.common.dao.BaseDao;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
......@@ -108,4 +109,12 @@ public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Int
List<OrderChild> selectInTransitOrderChildByOrderGoodsNo(String orderGoodsNo);
BigDecimal getLinePoundDifferenceAvg(@Param("sendAddressId") Integer sendAddressId,
@Param("receiveAddressId") Integer receiveAddressId,
@Param("beginTime") String beginTime);
int getLineArriveSendAddressToUnloadTimeAvg(@Param("sendAddressId") Integer sendAddressId,
@Param("receiveAddressId") Integer receiveAddressId,
@Param("beginTime") String beginTime);
}
......@@ -22,6 +22,7 @@ import com.msl.common.dao.impl.BaseDaoImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
......@@ -372,4 +373,16 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
return baseMapper.selectList(lQrWrapper().eq(OrderChild::getOrderGoodsNo, orderGoodsNo)
.lt(OrderChild::getStatus, OrderChildEnum.Status.COMPLETE.getCode())
); }
@Override
public BigDecimal getLinePoundDifferenceAvg(Integer sendAddressId, Integer receiveAddressId, String beginTime) {
return baseMapper.getLinePoundDifferenceAvg(sendAddressId, receiveAddressId, beginTime);
}
@Override
public int getLineArriveSendAddressToUnloadTimeAvg(Integer sendAddressId, Integer receiveAddressId, String beginTime) {
return baseMapper.getLineArriveSendAddressToUnloadTimeAvg(sendAddressId, receiveAddressId, beginTime);
}
}
......@@ -3,19 +3,18 @@ package com.clx.performance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.enums.OrderChildEnum;
import com.clx.performance.model.OrderChild;
import com.clx.performance.param.app.PageOrderChildOfDriverParam;
import com.clx.performance.param.app.PageOrderChildOfDriverSearchParam;
import com.clx.performance.param.pc.PageCarrierOrderChildParam;
import com.clx.performance.param.pc.PagePoundAuditParam;
import com.clx.performance.sqlProvider.OrderChildSqlProvider;
import com.clx.performance.sqlProvider.OrderGoodsSqlProvider;
import com.clx.performance.vo.app.OrderChildVO;
import com.clx.performance.vo.pc.PageCarrierOrderChildVO;
import com.clx.performance.vo.pc.PageOrderChildPoundAuditVO;
import org.apache.ibatis.annotations.*;
import java.math.BigDecimal;
import java.util.List;
......@@ -48,4 +47,22 @@ public interface OrderChildMapper extends BaseMapper<OrderChild> {
@UpdateProvider(type = OrderChildSqlProvider.class, method = "batchUpdateOrderChildStatus")
Integer updateOrderGoodsSetResidueWeight(@Param(value = "status") Integer status, @Param(value = "ids") List<Integer> ids);
@Select("select AVG((load_net-unload_net)/load_net) from order_child " +
" where send_address_id = #{sendAddressId} " +
" and receive_address_id = #{receiveAddressId} " +
" and status >= 90 and status <= 100 " +
" and pay_time >= #{beginTime}")
BigDecimal getLinePoundDifferenceAvg(@Param("sendAddressId") Integer sendAddressId,
@Param("receiveAddressId") Integer receiveAddressId,
@Param("beginTime") String beginTime);
@Select("select AVG(TIMESTAMPDIFF(SECOND, unload_time, arrive_send_time)) from order_child " +
" where send_address_id = #{sendAddressId} " +
" and receive_address_id = #{receiveAddressId} " +
" and status >= 90 and status <= 100 " +
" and pay_time >= #{beginTime}")
int getLineArriveSendAddressToUnloadTimeAvg(@Param("sendAddressId") Integer sendAddressId,
@Param("receiveAddressId") Integer receiveAddressId,
@Param("beginTime") String beginTime);
}
\ No newline at end of file
package com.clx.performance.service.child;
import java.util.HashMap;
public interface CarrierOrderChildService {
HashMap<String, Object> getLineStatistics(Integer sendAddressId, Integer receiveAddressId);
}
package com.clx.performance.service.impl.child;
import com.clx.performance.dao.OrderChildDao;
import com.clx.performance.service.child.CarrierOrderChildService;
import com.clx.performance.utils.LocalDateTimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.HashMap;
@Slf4j
@Service
public class CarrierOrderChildServiceImpl implements CarrierOrderChildService {
@Autowired
private OrderChildDao orderChildDao;
@Override
public HashMap<String, Object> getLineStatistics(Integer sendAddressId, Integer receiveAddressId) {
// 磅差
String beginTime = LocalDateTimeUtils.getStringDayStart(LocalDateTime.now().minusDays(7));
BigDecimal linePoundDifferenceAvg = orderChildDao.getLinePoundDifferenceAvg(sendAddressId, receiveAddressId, beginTime);
// 时长
beginTime = LocalDateTimeUtils.getStringDayStart(LocalDateTime.now().minusMonths(1));
int timeAvg = orderChildDao.getLineArriveSendAddressToUnloadTimeAvg(sendAddressId, receiveAddressId, beginTime);
HashMap<String, Object> map = new HashMap<>();
map.put("poundDifferenceAvg",linePoundDifferenceAvg.setScale(2, RoundingMode.HALF_UP));
map.put("timeAvg",timeAvg/60);
return map;
}
}
......@@ -155,6 +155,10 @@ public class LocalDateTimeUtils {
return formatTime(parseTime(time).withHour(0).withMinute(0).withSecond(0).withNano(0));
}
public static String getStringDayStart(LocalDateTime time) {
return formatTime(time.withHour(0).withMinute(0).withSecond(0).withNano(0));
}
public static LocalDateTime getDayStart(String time) {
return parseTime(time).withHour(0).withMinute(0).withSecond(0).withNano(0);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论