Revert "定时统计客户当前订单状态"

This reverts commit e55e848589.
master
YIN 2025-01-13 09:54:52 +08:00
parent b07e9c8cd2
commit d05e9db96f
7 changed files with 95 additions and 319 deletions

View File

@ -1,9 +1,6 @@
package com.cpxt.web.task; package com.cpxt.web.task;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cpxt.biz.domain.BizCar; import com.cpxt.biz.domain.BizCar;
import com.cpxt.biz.domain.BizCarState; import com.cpxt.biz.domain.BizCarState;
@ -24,8 +21,6 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
@Component("getLocationTask") @Component("getLocationTask")
@ -33,19 +28,11 @@ public class GetLocationTask {
// 域名 // 域名
private static final String ADDRESS = "http://api.e6yun.com/"; private static final String ADDRESS = "http://api.e6yun.com/";
private static final String APP_KEY_JSON = "[{ 'APP_KEY':'FEB9F91D-BCD7-4DC2-97D1-CB599EEAF9D5','SECRET_KEY':'A8211E8F-9E95-4C80-9414-CD5E1F675FEF' }, " +
"{ 'APP_KEY':'ECB3CDEA-ACD1-4E62-840D-717DCFBEAE79','SECRET_KEY':'BE3544F5-C488-41E8-9DA5-0172BF767210' }]";
// 公钥 // 公钥
private static final String APP_KEY = "FEB9F91D-BCD7-4DC2-97D1-CB599EEAF9D5"; private static final String APP_KEY = "FEB9F91D-BCD7-4DC2-97D1-CB599EEAF9D5";
// 密钥 // 密钥
private static final String SECRET_KEY = "A8211E8F-9E95-4C80-9414-CD5E1F675FEF"; private static final String SECRET_KEY = "A8211E8F-9E95-4C80-9414-CD5E1F675FEF";
// 公钥
private static final String APP_KEY2 = "ECB3CDEA-ACD1-4E62-840D-717DCFBEAE79";
// 密钥
private static final String SECRET_KEY2 = "BE3544F5-C488-41E8-9DA5-0172BF767210";
/*添加代码 begin*/ /*添加代码 begin*/
private static GetLocationTask getLocationTask; private static GetLocationTask getLocationTask;
@ -67,15 +54,8 @@ public class GetLocationTask {
// 同步车辆定位数据 // 同步车辆定位数据
public void syncLocationData(){ public void syncLocationData(){
JSONArray array = JSONUtil.parseArray(APP_KEY_JSON);
for (int i = 0; i < array.size(); i++) {
JSONObject apikey = array.getJSONObject(i);
String APPKEY = apikey.getStr("APP_KEY");
String APPSECRET = apikey.getStr("SECRET_KEY");
// 创建 E6SdkApi 以使用SDK API // 创建 E6SdkApi 以使用SDK API
E6SdkApi e6SdkApi = new E6SdkApi(ADDRESS, APPKEY, APPSECRET); E6SdkApi e6SdkApi = new E6SdkApi(ADDRESS, APP_KEY, SECRET_KEY);
try { try {
// 通过 e6SdkApi 来使用API // 通过 e6SdkApi 来使用API
GetVehicleInfoVO vehicleInfoVO = e6SdkApi.GetVehcileInfo("-1"); GetVehicleInfoVO vehicleInfoVO = e6SdkApi.GetVehcileInfo("-1");
@ -84,12 +64,10 @@ public class GetLocationTask {
if (Helper.FInt(vehicleInfoVO.getCode())==1){ if (Helper.FInt(vehicleInfoVO.getCode())==1){
List<VehicleInfoResp> list = vehicleInfoVO.getData(); List<VehicleInfoResp> list = vehicleInfoVO.getData();
for (VehicleInfoResp info : list) { for (VehicleInfoResp info : list) {
String serialNo = info.getEquipCode(); String carNo = info.getVehicleNO();
BizCar dbcar = getLocationTask.carMapper.selectBySerialNo(serialNo); BizCar dbcar = getLocationTask.carMapper.selectByCarNo(carNo);
if (dbcar!=null){ if (dbcar!=null){
Long carId = dbcar.getId();
// String carNo = dbcar.getCarNo();
BizCarState newstate = new BizCarState(); BizCarState newstate = new BizCarState();
newstate.setCarId(dbcar.getId()); newstate.setCarId(dbcar.getId());
@ -156,7 +134,7 @@ public class GetLocationTask {
newstate.setCommIds(info.getCommIds()); newstate.setCommIds(info.getCommIds());
// 更新实时定位信息 // 更新实时定位信息
BizCarState carState = getLocationTask.stateMapper.selectBizCarStateByCarId(carId); BizCarState carState = getLocationTask.stateMapper.selectByCarNo(carNo);
if (carState!=null){ if (carState!=null){
newstate.setId(carState.getId()); newstate.setId(carState.getId());
getLocationTask.stateMapper.updateById(newstate); getLocationTask.stateMapper.updateById(newstate);
@ -181,8 +159,6 @@ public class GetLocationTask {
// 异常捕获 // 异常捕获
e.printStackTrace(); e.printStackTrace();
} }
}
} }
} }

View File

@ -7,13 +7,11 @@ import com.cpxt.biz.domain.BizCustomerWarehouse;
import com.cpxt.biz.domain.BizOrder; import com.cpxt.biz.domain.BizOrder;
import com.cpxt.biz.domain.BizOrderTask; import com.cpxt.biz.domain.BizOrderTask;
import com.cpxt.biz.mapper.*; import com.cpxt.biz.mapper.*;
import com.cpxt.common.utils.DateUtils;
import com.cpxt.common.utils.Helper; import com.cpxt.common.utils.Helper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -59,15 +57,6 @@ public class OrderTask {
for (Long shopId : shopIds ) { for (Long shopId : shopIds ) {
BizOrder order = new BizOrder(); BizOrder order = new BizOrder();
order.setOrderSn(getNewOrderSn()); order.setOrderSn(getNewOrderSn());
if (task.getOrderDateMode()==2){
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, 1);
Date tomorrow = calendar.getTime();
order.setOrderDate(tomorrow);
}else{
order.setOrderDate(new Date());
}
order.setCustomerId(task.getCustomerId()); order.setCustomerId(task.getCustomerId());
order.setCustomerName(task.getCustomerName()); order.setCustomerName(task.getCustomerName());

View File

@ -46,21 +46,6 @@ public class StatTask {
private StatCarMapper statCarMapper; private StatCarMapper statCarMapper;
@Autowired @Autowired
private StatDriverMapper statDriverMapper; private StatDriverMapper statDriverMapper;
@Autowired
private BizOrderMapper orderMapper;
@Autowired
private BizCustomerMapper customerMapper;
@Autowired
private BizCustomerRouteMapper routeMapper;
@Autowired
private BizCustomerShopMapper shopMapper;
@Autowired
private BizCustomerStateMapper customerStateMapper;
@Autowired
private BizCustomerRouteStateMapper routeStateMapper;
@Autowired
private BizCustomerShopStateMapper shopStateMapper;
@PostConstruct @PostConstruct
public void init(){ public void init(){
@ -71,132 +56,6 @@ public class StatTask {
statTask.driverMapper = this.driverMapper; statTask.driverMapper = this.driverMapper;
statTask.stateMapper = this.stateMapper; statTask.stateMapper = this.stateMapper;
statTask.trackMapper = this.trackMapper; statTask.trackMapper = this.trackMapper;
statTask.orderMapper = this.orderMapper;
statTask.customerMapper = this.customerMapper;
statTask.routeMapper = this.routeMapper;
statTask.shopMapper = this.shopMapper;
statTask.customerStateMapper = this.customerStateMapper;
statTask.routeStateMapper = this.routeStateMapper;
statTask.shopStateMapper = this.shopStateMapper;
}
public void statCustomerData(){
Date now = new Date();
// 统计各路线平均配送时间
List<Map> route_avgtime_list = statTask.routeStateMapper.selectAvgTimes();
for (Map item : route_avgtime_list) {
int routeId = Helper.FInt(item.get("route_id"));
int avgtimes = Helper.FInt(item.get("avgtimes"));
if (routeId>0) {
BizCustomerRouteState routeState = statTask.routeStateMapper.selectOneByRouteId(routeId);
if (routeState==null || routeState.getId()==0)
routeState = new BizCustomerRouteState();
routeState.setRouteId(routeId);
routeState.setAvgTimes(avgtimes);
if (Helper.FInt(routeState.getId())>0)
statTask.routeStateMapper.updateById(routeState);
else
statTask.routeStateMapper.insert(routeState);
}
}
// 统计各路线今日订单数据
List<Map> route_order_count_list = statTask.routeStateMapper.selectOrderCount();
for (Map item : route_order_count_list) {
int routeId = Helper.FInt(item.get("route_id"));
int order_count = Helper.FInt(item.get("order_count"));
int finish_count = Helper.FInt(item.get("finish_count"));
if (routeId>0) {
BizCustomerRouteState routeState = statTask.routeStateMapper.selectOneByRouteId(routeId);
if (routeState==null || routeState.getId()==0)
routeState = new BizCustomerRouteState();
routeState.setRouteId(routeId);
routeState.setTodayOrders(order_count);
routeState.setFinishOrders(finish_count);
if (Helper.FInt(routeState.getId())>0)
statTask.routeStateMapper.updateById(routeState);
else
statTask.routeStateMapper.insert(routeState);
}
}
// 统计各路线当前订单数据
List<Map> route_order_list = statTask.routeStateMapper.selectCurrentOrder();
for (Map item : route_order_list) {
int routeId = Helper.FInt(item.get("route_id"));
String orderSn = Helper.NStr(item.get("order_sn"));
int carId = Helper.FInt(item.get("car_id"));
int driverId = Helper.FInt(item.get("driver_id"));
int copilotId = Helper.FInt(item.get("copilot_id"));
if (routeId>0) {
BizCustomerRouteState routeState = statTask.routeStateMapper.selectOneByRouteId(routeId);
if (routeState==null || routeState.getId()==0)
routeState = new BizCustomerRouteState();
routeState.setRouteId(routeId);
routeState.setCurrentOrder(orderSn);
routeState.setCurrentCarId(carId);
routeState.setCurrentDriverId(driverId);
routeState.setCurrentCopilotId(copilotId);
if (Helper.FInt(routeState.getId())>0)
statTask.routeStateMapper.updateById(routeState);
else
statTask.routeStateMapper.insert(routeState);
}
}
// 统计各门店平均配送时间
List<Map> shop_avgtime_list = statTask.shopStateMapper.selectAvgTimes();
for (Map item : shop_avgtime_list) {
int shopId = Helper.FInt(item.get("shop_id"));
int avgtimes = Helper.FInt(item.get("avgtimes"));
if (shopId>0) {
BizCustomerShopState state = statTask.shopStateMapper.selectOneByShopId(shopId);
if (state==null || state.getId()==0)
state = new BizCustomerShopState();
state.setShopId(shopId);
state.setAvgTimes(avgtimes);
if (Helper.FInt(state.getId())>0)
statTask.shopStateMapper.updateById(state);
else
statTask.shopStateMapper.insert(state);
}
}
// 统计各门店平均配送时间
List<Map> shop_order_list = statTask.shopStateMapper.selectCurrentOrder();
for (Map item : shop_order_list) {
int shopId = Helper.FInt(item.get("shop_id"));
int avgtimes = Helper.FInt(item.get("avgtimes"));
if (shopId>0) {
BizCustomerShopState state = statTask.shopStateMapper.selectOneByShopId(shopId);
if (state==null || state.getId()==0)
state = new BizCustomerShopState();
state.setShopId(shopId);
state.setIsFinish(Helper.FInt(item.get("order_status"))==3?1:0);
state.setCurrentOrder(Helper.NStr(item.get("order_sn")));
state.setCurrentCarId(Helper.FInt(item.get("car_id")));
state.setCurrentDriverId(Helper.FInt(item.get("driver_id")));
state.setCurrentCopilotId(Helper.FInt(item.get("copilot_id")));
if (Helper.FInt(state.getId())>0)
statTask.shopStateMapper.updateById(state);
else
statTask.shopStateMapper.insert(state);
}
}
} }
// 定时统计车辆使用情况 // 定时统计车辆使用情况

View File

@ -291,11 +291,6 @@ public class BizOrder
/** 备注 */ /** 备注 */
private String remark; private String remark;
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "所属日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date orderDate;
// 下单开始时间 // 下单开始时间
@TableField(exist = false) @TableField(exist = false)
private String beginTime; private String beginTime;

View File

@ -29,9 +29,6 @@ public interface BizCarMapper extends BaseMapper<BizCar>
@Select("select * from biz_car where car_no = #{carNo}") @Select("select * from biz_car where car_no = #{carNo}")
BizCar selectByCarNo(String carNo); BizCar selectByCarNo(String carNo);
@Select("select * from biz_car where serial_no = #{serialNo}")
BizCar selectBySerialNo(String serialNo);
@Select("select * from ${tableName} where gps_time >= #{startTime} and gps_time <= #{endTime}") @Select("select * from ${tableName} where gps_time >= #{startTime} and gps_time <= #{endTime}")
List<Map> selectBizTrackList(@Param("tableName") String tableName,@Param("startTime") String startTime,@Param("endTime") String endTime); List<Map> selectBizTrackList(@Param("tableName") String tableName,@Param("startTime") String startTime,@Param("endTime") String endTime);

View File

@ -3,10 +3,6 @@ package com.cpxt.biz.mapper;
import com.cpxt.biz.domain.BizCustomerRouteState; import com.cpxt.biz.domain.BizCustomerRouteState;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/** /**
* @author LuoJian * @author LuoJian
@ -17,22 +13,6 @@ import java.util.Map;
@Mapper @Mapper
public interface BizCustomerRouteStateMapper extends BaseMapper<BizCustomerRouteState> { public interface BizCustomerRouteStateMapper extends BaseMapper<BizCustomerRouteState> {
@Select("select * from biz_customer_route_state where route_id = #{routeId}")
BizCustomerRouteState selectOneByRouteId(int routeId);
@Select("select route_id, ROUND(AVG(TIME_TO_SEC(TIMEDIFF(arrive_time, start_time ))),0) AS avgtimes from biz_order " +
" where order_status = 3 and start_time is not null and arrive_time is not null group by route_id")
List<Map> selectAvgTimes();
@Select("select route_id, count(id) order_count, sum(case when order_status = 3 then 1 else 0 end) finish_count " +
" from biz_order where order_date = curdate() group by route_id ")
List<Map> selectOrderCount();
@Select("select * from (select distinct order_sn,order_status, route_id,car_id, driver_id, copilot_id " +
" from biz_order where order_date = curdate() and (order_status = '1' or order_status = '2') " +
" order by create_time asc ) as t group by t.route_id ")
List<Map> selectCurrentOrder();
} }

View File

@ -1,13 +1,8 @@
package com.cpxt.biz.mapper; package com.cpxt.biz.mapper;
import com.cpxt.biz.domain.BizCustomerRouteState;
import com.cpxt.biz.domain.BizCustomerShopState; import com.cpxt.biz.domain.BizCustomerShopState;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/** /**
* @author LuoJian * @author LuoJian
@ -18,21 +13,6 @@ import java.util.Map;
@Mapper @Mapper
public interface BizCustomerShopStateMapper extends BaseMapper<BizCustomerShopState> { public interface BizCustomerShopStateMapper extends BaseMapper<BizCustomerShopState> {
@Select("select * from biz_customer_shop_state where shop_id = #{routeId}")
BizCustomerShopState selectOneByShopId(int shopId);
@Select("select shop_id, ROUND(AVG(TIME_TO_SEC(TIMEDIFF(arrive_time, start_time ))),0) AS avgtimes from biz_order " +
" where order_status = 3 and start_time is not null and arrive_time is not null group by shop_id")
List<Map> selectAvgTimes();
@Select("select shop_id, count(id) order_count, sum(case when order_status = 3 then 1 else 0 end) finish_count " +
" from biz_order where order_date = curdate() group by shop_id ")
List<Map> selectOrderCount();
@Select("select * from (select distinct order_sn,order_status, shop_id, car_id, driver_id, copilot_id " +
" from biz_order where order_date = curdate() and (order_status = '1' or order_status = '2') " +
" order by create_time asc ) as t group by t.shop_id ")
List<Map> selectCurrentOrder();
} }