Commit d39deb65 authored by lanbaoming's avatar lanbaoming

2024-05-13新功能和运维BUG处理

parent 48fbaa1a
package cn.iocoder.yudao.framework.apollo.core.event.Order;
import lombok.Data;
/*
lanbm 2024-05-13 add
在创建订单或修改订单时计算客户业绩类型
*/
@Data
public class CalculateOrderYeJiTypeEvent {
/*
业绩归属方ID
*/
private long customerId;
/*
订单id
*/
private Long orderId;
}
......@@ -8,8 +8,11 @@ import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.AssignConfirmedCustomerEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Customer.ReceiveCustomerCalTypeEvent;
import cn.iocoder.yudao.framework.apollo.core.event.AutoProcessNotCustomerServiceExceptionEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Customer.ReceiveCustomerCalTypeEvent;
import cn.iocoder.yudao.framework.apollo.core.event.QueryEstimateEnterOpenSeaTimeEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Customer.CalculateCustomerTypeEvent;
import cn.iocoder.yudao.framework.apollo.core.vo.ApplyInfoVO;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
......@@ -511,6 +514,19 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
//分配确认接收回调
applicationContext.publishEvent(new AssignConfirmedCustomerEvent(customerId,customerNew.getCustomerService()));
//完善客户信息顺便确认接收,对客户类型做逻辑运算
//lanbm 2024-05-08 添加接收确认后判断客户是新客户还是老客户逻辑
//前面的逻辑有可能改了客户的业绩类型,需要再次获取客户信息
CustomerDO customer2 = customerMapper.selectById(customerId);
ReceiveCustomerCalTypeEvent event=new ReceiveCustomerCalTypeEvent();
event.setCustomerId(customerId);
event.setCustomerNumber(customer2.getNumber());
event.setIsNew(customer2.getIsNew());
applicationContext.publishEvent(event);
//end lanbm 2024-05-08 添加接收确认后判断客户是新客户还是老客户逻辑
} else {
//纪录编辑日志
customerOperateLogCreateReqVO.setOperateType(CustomerOperateTypeEnum.UPDATE.getValue())
......@@ -2377,6 +2393,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
// 当新客户(已有已装柜订单)分配给其他客户经理,客户经理接收后,业绩类型变成老客户
// 其他情况不需更新注:业绩类型只会从新客户更新到老客户,不反向更新
if (Boolean.TRUE.equals(customer.getIsNew())) {
//根据部门业绩日志表中的信息把新客户变为老客户 lanbm 2024-05-08 添加注释
//ecw_target_log 部门业绩日志表
customerMapper.updateCustomerIsNewToOldByTargetLog(customerId);
}
......@@ -2398,6 +2416,15 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
//分配确认接收回调
applicationContext.publishEvent(new AssignConfirmedCustomerEvent(customerId,customerService));
//lanbm 2024-05-08 添加接收确认后判断客户是新客户还是老客户逻辑
//前面的逻辑有可能改了客户的业绩类型,需要再次获取客户信息
CustomerDO customer2 = customerMapper.selectById(customerId);
ReceiveCustomerCalTypeEvent event=new ReceiveCustomerCalTypeEvent();
event.setCustomerId(customerId);
event.setCustomerNumber(customer2.getNumber());
event.setIsNew(customer2.getIsNew());
applicationContext.publishEvent(event);
//end lanbm 2024-05-08 添加接收确认后判断客户是新客户还是老客户逻辑
}
private Date getEstimateTimeByCustomerStatus(CustomerDO customer, Date now) {
......@@ -2421,7 +2448,7 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
@Override
@Transactional(rollbackFor = Exception.class)
public void catchCustomer(Long customerId) {
//lanbm 2024-05-07 添加客户业绩类型逻辑
//捞取公海池客户
CustomerDO customer = customerMapper.selectById(customerId);
if (customer == null) {
......@@ -2441,6 +2468,7 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
throw exception(ErrorCodeConstants.CUSTOMER_CATCH_ERROR);
}
// if (!user.getPostIds().contains(adminUserApi.getActiveCustomerServicePostId())) {
//判断当前用户的角色 lanbm 2024-05-07 添加注释
if (!user.getPostIds().contains(2L) && !user.getPostIds().contains(19L)) {
throw exception(ErrorCodeConstants.CUSTOMER_CATCH_ERROR);
}
......@@ -2501,6 +2529,7 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
Long newCustomerService = loginUserId;
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
//保存客户捞取记录 lanbm 2024-05-07 添加注释
CustomerOperateLogCreateReqVO customerOperateLogCreateReqVO = new CustomerOperateLogCreateReqVO()
.setOperator(loginUser == null ? null : loginUser.getId())
.setOperatorName(loginUser == null ? null : loginUser.getNickname())
......@@ -2520,15 +2549,29 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
log.info("公海池捞取客户[{}]包含海运整柜,设置不掉入公海", customer.getId());
}
// 记录catch时间
//记录catch时间
//对应的数据库表为 ecw_customer_public_catch_log
customerPublicCatchLogMapper.insert(new CustomerPublicCatchLogDO(null, customer.getId(), loginUserId));
//捞取完后 自动处理未分配客户经理异常
applicationContext.publishEvent(new AutoProcessNotCustomerServiceExceptionEvent(customer.getNumber()));
//lanbm 2024-05-07 添加捞取后修改客户是否为新客户的相关逻辑
CalculateCustomerTypeEvent cevent=new CalculateCustomerTypeEvent();
cevent.setCustomerNumber(customer.getNumber());
cevent.setStatus(customer.getStatus());
cevent.setOldCustomerService(newCustomerService);
cevent.setOldCustomerService(oldCustomerService);
cevent.setCustomerId(customer.getId());
applicationContext.publishEvent(cevent);
//end lanbm 2024-05-07 添加捞取后修改客户是否为新客户的相关逻辑
}
/*
接收客户,lanbm 2024-05-08 添加客户业绩类型逻辑运算
*/
public void receiveCustomer(Long customerId, Long customerServiceId) {
CustomerDO customerDO = customerMapper.selectById(customerId);
if (customerDO != null) {
......@@ -2581,6 +2624,18 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
//分配确认接收回调
applicationContext.publishEvent(new AssignConfirmedCustomerEvent(customerId,customerDO.getCustomerService()));
//报价成功后就会确认接收客户,所以在此做客户类型逻辑运算
//lanbm 2024-05-08 add
//lanbm 2024-05-08 添加接收确认后判断客户是新客户还是老客户逻辑
//前面的逻辑有可能改了客户的业绩类型,需要再次获取客户信息
CustomerDO customer2 = customerMapper.selectById(customerId);
ReceiveCustomerCalTypeEvent event=new ReceiveCustomerCalTypeEvent();
event.setCustomerId(customerId);
event.setCustomerNumber(customer2.getNumber());
event.setIsNew(customer2.getIsNew());
applicationContext.publishEvent(event);
//end lanbm 2024-05-08 添加接收确认后判断客户是新客户还是老客户逻辑
}
}
}
......
......@@ -129,6 +129,7 @@ public class CustomerController {
@Resource
private FileMakeApi fileMakeApi;
public CustomerController() {
}
......@@ -291,6 +292,7 @@ public class CustomerController {
//完善信息要确认接收
updateReqVO.setIsCustomerServiceConfirmed(true);
//lanbm 2024-05-08 完善客户信息确认接收时要计算客户的业绩类型
return this.updateCustomer(updateReqVO);
}
......@@ -448,8 +450,6 @@ public class CustomerController {
}
// @GetMapping("/handover/approval/info")
// @ApiOperation("获取客户移交的审批详情")
// // @PreAuthorize("@ss.hasPermission('ecw:customer:query')")
......@@ -510,12 +510,11 @@ public class CustomerController {
@ApiOperation("跟进客户确认接收")
@PreAuthorize("@ss.hasPermission('ecw:customer:treat-accept')")
@Idempotent(timeout = 5)
public CommonResult<Boolean> confirm(@Valid @RequestBody CustomerConfirmReqVO customerConfirmReqVO) {
public CommonResult<Boolean> confirm(
@Valid @RequestBody CustomerConfirmReqVO customerConfirmReqVO) {
//lanbm 2024-05-08 添加接收确认后判断客户是新客户还是老客户逻辑
Long id = customerConfirmReqVO.getCustomerId();
customerService.confirmCustomer(id);
return success(true);
}
......@@ -565,7 +564,8 @@ public class CustomerController {
@PreAuthorize("@ss.hasPermission('ecw:customer:sea-gain')")
@Idempotent(timeout = 5)
public CommonResult<Boolean> catchCustomer(@RequestParam("id") Long id) {
//公海池捞取客户,修改客户业绩类型需要调整此处的逻辑
//lanbm 2024-05-07 处理
customerService.catchCustomer(id);
return success(true);
......@@ -731,7 +731,6 @@ public class CustomerController {
}
@PutMapping("/change-customer-fcl")
@ApiOperation("设置客户为海运整柜客户/非海运整柜客户")
@PreAuthorize("@ss.hasPermission('ecw:customer:fcl')")
......@@ -756,7 +755,6 @@ public class CustomerController {
}
@PutMapping("/update-customer-to-old")
@ApiOperation("根据客户经理id更新成交状态的新客户为老客户")
@ApiImplicitParam(name = "customerServiceId", value = "客户经理id", required = true, example = "1024", dataTypeClass = Long.class)
......
......@@ -63,8 +63,6 @@ public class CustomerAnalysisControl {
@Autowired
private CustomerAnalysisService customerAnalysisService;
@Resource
private CustomerAnalysisService2 customerAnalysisService2;
//报表权限信息
@Resource
......@@ -73,8 +71,7 @@ public class CustomerAnalysisControl {
@Resource
private RedisHelper redisHelper;
@Resource
private view_order_businesstimeService vieworderbusinesstimeService;
private List<view_order_businesstime> listBData = null;
private List<CustomerAnalysisResp> objListResult = null;
......
package cn.iocoder.yudao.module.delivery.listener;
import cn.iocoder.yudao.framework.apollo.core.event.Order.CalculateOrderVValueEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Order.CalculateOrderYeJiTypeEvent;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.customer.service.customer.CustomerService;
import cn.iocoder.yudao.module.delivery.entity.EcwVz;
import cn.iocoder.yudao.module.delivery.service.EcwVzService;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.ORDER_EXPRESS_NUMBER_TOO_LONG;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
import static cn.iocoder.yudao.module.delivery.enums.ErrorCodeConstants.VCONFIG_NOT_EXISTS;
/*
计算订单V值计算 海运已装柜,空运已入仓 计算V值
lanbm 2024-05-13 add
*/
@Component("CalculateOrderVValueListener")
@AllArgsConstructor
@Slf4j
public class CalculateOrderVValueListener {
@Autowired
private OrderService orderService;
@Autowired
private EcwVzService ecwVzService;
@EventListener(CalculateOrderVValueEvent.class)
public void CalculateOrderVValuePushEvent(
CalculateOrderVValueEvent event) {
OrderDO orderDO = orderService.getById(event.getOrderId());
if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
}
//订单状态为已入仓之后的状态,其他状态是否排除,后续和客户确认,先按此逻辑处理
int nS = orderDO.getStatus();
if (nS >= 5) {
//查询配置参数信息
EcwVz temp = null;
BigDecimal CalVvalue = new BigDecimal(0);
if (orderDO.getTransportId() == 1) {
//海运计算V值
temp = ecwVzService.getOne(new LambdaQueryWrapperX<EcwVz>()
.eqIfPresent(EcwVz::getTitleZh, "M3"));
if (temp == null) {
throw exception(VCONFIG_NOT_EXISTS);
}
CalVvalue = new BigDecimal(temp.getVz()).divide(orderDO.getSumVolume());
} else if (orderDO.getTransportId() == 3) {
//空运计算V值
temp = ecwVzService.getOne(new LambdaQueryWrapperX<EcwVz>()
.eqIfPresent(EcwVz::getTitleZh, "KG"));
if (temp == null) {
throw exception(VCONFIG_NOT_EXISTS);
}
CalVvalue = new BigDecimal(temp.getVz()).divide(orderDO.getSumWeight());
}
//计算业绩产生时间
if (orderDO.getRucangTime() == null) {
event.setYejiCreateDate(new Date());
} else {
event.setYejiCreateDate(orderDO.getRucangTime());
}
orderService.UpdateOrderVValue(event.getOrderId(), CalVvalue,
event.getYejiCreateDate());
}
}
}
package cn.iocoder.yudao.module.delivery.listener;
import cn.iocoder.yudao.framework.apollo.core.event.Customer.CalculateCustomerTypeEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Order.CalculateOrderYeJiTypeEvent;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.customer.service.customer.CustomerService;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.delivery.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
/*
计算订单业绩类型监听
lanbm 2024-05-13 add
*/
@Component("CalculateOrderYeJiTypeListener")
@AllArgsConstructor
@Slf4j
public class CalculateOrderYeJiTypeListener {
@Autowired
private OrderService orderService;
@Autowired
private CustomerService customerService;
@EventListener(CalculateOrderYeJiTypeEvent.class)
public void CalculateOrderYeJiTypePushEvent(
CalculateOrderYeJiTypeEvent event) {
OrderDO orderDO = orderService.getById(event.getOrderId());
if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
}
//获取订单中计算号的业绩归属客户ID
event.setCustomerId(orderDO.getCustomerId());
CustomerDO customerDO = customerService.getById(event.getCustomerId());
if (customerDO == null) {
throw exception(CUSTOMER_NOT_EXISTS);
}
int isNew = 0;
if (customerDO.getIsNew() == true)
isNew = 1;//新客户业绩类型
else
isNew = 0;//老客户业绩类型
orderService.UpdateOrderYeJiType(event.getOrderId(), isNew);
}
}
......@@ -76,17 +76,14 @@ public class CustomerAnalysisExcelExportListener {
concat("客户分析报表.xlsx");
List<CustomerAnalysisResp> list =
customerAnalysisService.getList(query);
customerAnalysisService.GetDataListResult(query);
//把查询列表转换位Excel对象
List<CustomerAnalysisExcelResp> listExel =
CustomerAnalysis.INSTANCE.convertList(list);
String path = ExcelUtils.write(dir, fileName,
"客户分析报表",
CustomerAnalysisExcelResp.class,
listExel);
// 获取到临时文件
File file = new File(path);
// 创建FileInputStream对象
......
......@@ -10,6 +10,8 @@ import java.util.List;
public interface CustomerAnalysisService {
PageResult<CustomerAnalysisResp> getListPage(CustomerAnalysisReq req)
throws JsonProcessingException;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment