Commit f8be029d authored by lanbaoming's avatar lanbaoming

2024-04-13提交新功能

parent 93bae80a
package cn.iocoder.yudao.framework.apollo.core.event.Customer;
import lombok.Data;
/*
移交,接收时计算客户的业绩类型
lanbm 2024-05-07 add
*/
@Data
public class ReceiveCustomerCalTypeEvent {
/**
* 客户编码
*/
private String customerNumber;
/*
客户ID
*/
private Long customerId;
/**
* 是否新客户
*/
private Boolean isNew;
}
......@@ -40,5 +40,17 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-customer-core</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-order-core</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</project>
......@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.delivery.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
......@@ -12,7 +13,9 @@ import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisExcelResp;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisResp;
import cn.iocoder.yudao.module.delivery.entity.orderdata.StatisticalSummary;
import cn.iocoder.yudao.module.delivery.service.SalesAnalysisService;
import cn.iocoder.yudao.module.delivery.service.StatisticalSummaryService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.file.FileMakeApi;
import cn.iocoder.yudao.module.system.api.file.dto.FileMakeReqDTO;
......@@ -46,6 +49,9 @@ public class SalesAnalysisControl {
@Autowired
private SalesAnalysisService salesAnalysisService;
@Resource
private StatisticalSummaryService statisticalSummaryService;
/*
数据字典项
*/
......@@ -55,58 +61,6 @@ public class SalesAnalysisControl {
@Resource
private FileMakeApi fileMakeApi;
/*
根据原始信息计算逻辑展示信息 lanbm 2024-04-29 add
*/
private SalesAnalysisResp calBis(SalesAnalysisResp r) {
String sTemp = "";
//付款方
if (r.getDrawee().equals("1")) {
if (r.getCfResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getCfResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getCfYeJiType().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getCfYeJiType().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "发货方";
} else if (r.getDrawee().equals("2")) {
if (r.getShResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getShResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getShYeJitype().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getShYeJitype().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "收货方";
} else if (r.getDrawee().equals("3")) {
if (r.getCfResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getCfResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getCfYeJiType().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getCfYeJiType().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "自定义";
}
r.setDraweeName(sTemp);
return r;
}
/*
客户分析列表 lanbm 2024-04-02 add
......@@ -115,58 +69,30 @@ public class SalesAnalysisControl {
public CommonResult<PageResult<SalesAnalysisResp>>
getListPage(@Valid SalesAnalysisReq query) {
System.out.println("订单分析查询条件:" + query);
/*
String jsonStr = JsonUtils.toJsonString(query);
JsonUtils.SaveLog(jsonStr);
*/
/*
SalesAnalysisReq query = JSON.parseObject(JSON.toJSONString(map),
SalesAnalysisReq.class);
*/
//订单状态
List<DictDataRespDTO> dic_order_status =
dictDataApi.getDictDatas("order_status");
Map<String, String> map_order_status = new HashMap<>();
for (DictDataRespDTO d : dic_order_status
) {
map_order_status.put(d.getValue(), d.getLabel());
}
PageResult<SalesAnalysisResp> pageResult =
salesAnalysisService.getListPage(query);
int nPm = query.getStart() + 1;
String sTemp = "";
for (SalesAnalysisResp r : pageResult.getList()
) {
r.setPx(nPm);
nPm++;
//订单状态
r.setStatusName(map_order_status.get(r.getStatus()));
String sType = "";
if (r.getOrdertype() == 2) {
//是重货,非泡货
sType = "是/否";
} else if (r.getOrdertype() == 3) {
sType = "否/是";
} else if (r.getOrdertype() == 1) {
sType = "普货";
}
r.setOrdertypeShow(sType);
//业务数据逻辑运算
r = calBis(r);
if (r.getUseweightunit() == null) r.setUseweightunit("无");
if (r.getUsevolumeunit() == null) r.setUsevolumeunit("无");
r.setZpUnitShow(r.getUseweightunit() + "/" + r.getUsevolumeunit());
}
return success(pageResult);
}
/*
获取销售统计数据 lanbm 2024-05-04 add
*/
@GetMapping("/getStatisticalSummary")
public CommonResult<StatisticalSummary> getStatisticalSummary(@Valid SalesAnalysisReq query) {
return success(statisticalSummaryService.GetStatisticalSummary(query));
}
/*
lanbm 2024-04-24 add
*/
......@@ -174,9 +100,8 @@ public class SalesAnalysisControl {
@ApiOperation("导出销售分析数据")
@OperateLog(type = EXPORT)
public CommonResult<Boolean> export(HttpServletResponse response,
@Valid SalesAnalysisReq Req)
@Valid SalesAnalysisReq Req)
throws IOException {
System.out.println("订单分析查询数据导出查询条件:" + Req);
FileMakeReqDTO reqDTO = new FileMakeReqDTO();
......
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.delivery.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.delivery.entity.*;
import cn.iocoder.yudao.module.delivery.entity.bar.CustomerReportBar;
import cn.iocoder.yudao.module.delivery.entity.bar.series;
......@@ -20,10 +21,10 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* (Employee)表控制层
* 销售统计报表控制层
*
* @author lanbm
* @since 2024-03-27 21:25:55
* @since 2024-03-27
*/
@RestController
@Api(tags = "管理后台 -统计报表")
......@@ -46,20 +47,30 @@ public class SalesReportControl {
lanbm 2024-04-01
*/
@PostMapping("/FirstCustomerCount")
public CommonResult<Integer> FirstCustomerCount(@RequestBody SalesReportReq Req) {
int nR = salesReportService.FirstCustomerCount(Req);
public CommonResult<SalesReportCusTarget> FirstCustomerCount(@RequestBody SalesReportReq Req) {
SalesReportCusTarget nR = salesReportService.FirstCustomerCount(Req);
return success(nR);
}
/*
lanbm 2024-05-09 add 统计一段时间成交的客户数
Get请求一定要注意参数类型
*/
@GetMapping("/CustomerTargetCount")
public CommonResult<SalesReportCusTarget> CustomerTargetCount(@Valid SalesReportReq Req) {
SalesReportCusTarget objR = salesReportService.CustomerTargetCount(Req);
return success(objR);
}
/*
按运输方式统计重量和方数
lanbm 2024-04-01
*/
@PostMapping("/SalesReportCount")
public CommonResult<SalesReportResp> SalesReportCount(@RequestBody SalesReportReq Req) {
String s = "";
SalesReportResp re = salesReportService.SalesReportCount(Req);
return success(re);
public CommonResult<List<SalesReportRespShow>> SalesReportCount(@RequestBody SalesReportReq Req) {
List<SalesReportRespShow> list = salesReportService.SalesReportCount(Req);
return success(list);
}
/*
......@@ -67,9 +78,9 @@ public class SalesReportControl {
lanbm 2024-04-01 add
*/
@PostMapping("/SalesReportList")
public CommonResult<Integer> SalesReportList(@RequestBody SalesReportReq Req) {
int nR = salesReportService.FirstCustomerCount(Req);
return success(nR);
public CommonResult<SalesReportCusTarget> SalesReportList(@RequestBody SalesReportReq Req) {
SalesReportCusTarget objR = salesReportService.FirstCustomerCount(Req);
return success(objR);
}
/*
......@@ -78,7 +89,6 @@ public class SalesReportControl {
@GetMapping("/getEChartData")
public CommonResult<CustomerReportBar>
getEChartData(@Valid SalesAnalysisReq query) {
CustomerReportBar customerReportBar = new CustomerReportBar();
yAxis y = new yAxis();
......
......@@ -67,6 +67,10 @@ public class SalesAnalysisReq extends PageParam {
*/
private String deptId;
/*
唛头查询类型
*/
private String SearchType5;
/*
唛头
*/
......
package cn.iocoder.yudao.module.delivery.entity;
import lombok.Data;
@Data
public class SalesReportCusTarget {
/*
当前成交客户数
*/
private int sumCustomerCount;
/*
对比成交客户数
*/
private int sumCustomerCountTb;
/*
同比结果显示信息
*/
private String TbShow;
}
......@@ -31,4 +31,21 @@ public class SalesReportReq {
对比年份
*/
private String duibiYear;
/*
统计年份
*/
private String curYear;
/*
开始日期
*/
private String sDate;
private String sDuiBiDate;
/*
结束日期
*/
private String eDate;
private String eDuiBiDate;
}
package cn.iocoder.yudao.module.delivery.entity;
import lombok.Data;
import java.math.BigDecimal;
/*
lanbm 2024-05-09 add
*/
@Data
public class SalesReportRespShow {
/*
当前数据
*/
private BigDecimal sumAll;
/*
对比数据
*/
private BigDecimal sumAllTb;
/*
同比结果显示信息
*/
private String TbShow;
}
package cn.iocoder.yudao.module.delivery.entity.orderdata;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
/*
lanbm 2024-05-03 add
*/
@Schema(description = "管理后台 - 订单汇总数据")
@Data
@ToString(callSuper = true)
public class StatisticalSummary {
/*
总汇总数据
*/
private int sumBox;
private BigDecimal sumM3;
private BigDecimal sumKG;
private BigDecimal sumV;
/*
新客户汇总数据
*/
private int sumBoxNew;
private BigDecimal sumM3New;
private BigDecimal sumKGNew;
private BigDecimal sumVNew;
/*
老客户汇总数据
*/
private int sumBoxOld;
private BigDecimal sumM3Old;
private BigDecimal sumKGOld;
private BigDecimal sumVOld;
}
package cn.iocoder.yudao.module.delivery.listener;
import cn.iocoder.yudao.framework.apollo.core.event.Customer.ReceiveCustomerCalTypeEvent;
import cn.iocoder.yudao.module.customer.service.customer.CustomerService;
import cn.iocoder.yudao.module.delivery.service.Impl.OrderServiceExtImpl;
import cn.iocoder.yudao.module.delivery.service.OrderServiceExt;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/*
移交,接收客户是计算客户业绩类型
lanbm 2024-05-07 add
*/
@Component("ReceiveCustomerCalTypeListener")
@AllArgsConstructor
@Slf4j
public class ReceiveCustomerCalTypeListener {
@Resource
private CustomerService customerService;
@Resource
private OrderServiceExt orderServiceExt;
@EventListener(ReceiveCustomerCalTypeEvent.class)
public void CalculateCustomerTypePushEvent(
ReceiveCustomerCalTypeEvent event) {
//CustomerServiceImpl confirmCustomer 函数中触发事件 客户经理直接确认接收
//CustomerServiceImpl receiveCustomer 函数中触发,移交,系统分配,接收时判断
//CustomerServiceImpl updateCustomer 函数中触发,完善客户信息
if (event.getIsNew() == true) {
//移交接收前是新客户
boolean bR = IsHavingRuCanOrder(event);
if (bR == true) {
//客户有订单已入仓且业绩归属客户方,接收后客户业绩类型,变更为老客户
customerService.updateCustomerNewOrOld(event.getCustomerId(),
false);
} else {
//客户没有订单已入仓,变更为新客户
//维持老客户不变,可不做任何逻辑操作
}
} else {
//移交接收前是老客户
//维持老客户不变,可不做任何逻辑操作
}
}
/*
判断客户是否有已入参订单
select COUNT(id) from ecw_target_log where deleted = 0 and customer_id = 17442
*/
private boolean IsHavingRuCanOrder(ReceiveCustomerCalTypeEvent event) {
//判断客户是否有已入参订单
//int a = orderServiceExt.IsHavingOrderConsignee(event);//收货方客户
//int b = orderServiceExt.IsHavingOrderConsignor(event);//发货方客户
/* int c=orderServiceExt.IsHavingOrder(event);
if (c==0)
return false;
else
return true;*/
return true;
}
}
......@@ -56,8 +56,7 @@ public class SalesAnalysisExcelExportListener {
if (!fileDir.exists()) {
fileDir.mkdirs();
}
String fileName =
event.getUserId().toString().
String fileName = event.getUserId().toString().
concat(StrUtil.DASHED).
concat(event.getUserType().toString()).
concat(StrUtil.DASHED).
......
package cn.iocoder.yudao.module.delivery.listener;
import lombok.Data;
@Data
public class TestEvent {
private String Name;
private int MsgType;
}
package cn.iocoder.yudao.module.delivery.listener;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Component("TestListener")
@AllArgsConstructor
@Slf4j
public class TestListener {
/*
监听指定类的消息
*/
@EventListener(TestEvent.class)
public void TestEventFun(
TestEvent event) {
System.out.println("测试监听:"+event);
}
}
......@@ -17,4 +17,10 @@ public interface SalesReportMapper {
int FirstCustomerCount(SalesReportReq Req);
/*
统计一段时间内客户成交数目,出重客户
lanbm 2024-05-09 add
*/
int CustomerTargetCount(SalesReportReq Req);
}
package cn.iocoder.yudao.module.delivery.mapper;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.orderdata.StatisticalSummary;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface StatisticalSummaryMapper {
StatisticalSummary GetStatisticalSummary(SalesAnalysisReq req);
}
package cn.iocoder.yudao.module.delivery.service.Impl;
import cn.iocoder.yudao.framework.apollo.core.event.Customer.ReceiveCustomerCalTypeEvent;
import cn.iocoder.yudao.module.delivery.entity.orderdata.OrderExt;
import cn.iocoder.yudao.module.delivery.mapper.OrderExtMapper;
import cn.iocoder.yudao.module.delivery.service.OrderServiceExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("OrderServiceExt")
public class OrderServiceExtImpl implements OrderServiceExt {
@Autowired
private OrderExtMapper orderExtMapper;
/*
客户为发货方是否有订单
*/
public int IsHavingOrderConsignor(ReceiveCustomerCalTypeEvent event) {
return orderExtMapper.IsHavingOrderConsignor(event);
}
/*
客户为收货方是否有订单
*/
public int IsHavingOrderConsignee(ReceiveCustomerCalTypeEvent event) {
return orderExtMapper.IsHavingOrderConsignee(event);
}
/*
上面2个函数废弃不用了,用此函数来判断客户是否已经产生了订单
*/
public int IsHavingOrder(ReceiveCustomerCalTypeEvent event) {
return orderExtMapper.IsHavingOrder(event);
}
}
package cn.iocoder.yudao.module.delivery.service.Impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.delivery.entity.*;
import cn.iocoder.yudao.module.delivery.mapper.SalesAnalysisMapper;
import cn.iocoder.yudao.module.delivery.service.SalesAnalysisService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
lanbm 2024-04-01
......@@ -20,25 +24,130 @@ public class SalesAnalysisImpl implements SalesAnalysisService {
@Autowired
private SalesAnalysisMapper salesAnalysisMapper;
public List<SalesAnalysisExcelResp> getList(SalesAnalysisReq req)
{
@Autowired
private DictDataApi dictDataApi;
public List<SalesAnalysisExcelResp> getList(SalesAnalysisReq req) {
return salesAnalysisMapper.getList(req);
}
/*
根据原始信息计算逻辑展示信息 lanbm 2024-04-29 add
*/
private SalesAnalysisResp calBis(SalesAnalysisResp r) {
String sTemp = "";
//付款方
if (r.getDrawee().equals("1")) {
if (r.getCfResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getCfResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getCfYeJiType().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getCfYeJiType().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "发货方";
} else if (r.getDrawee().equals("2")) {
if (r.getShResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getShResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getShYeJitype().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getShYeJitype().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "收货方";
} else if (r.getDrawee().equals("3")) {
if (r.getCfResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getCfResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getCfYeJiType().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getCfYeJiType().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "自定义";
}
r.setDraweeName(sTemp);
//计算提货率 lanbm 2024-05-02 add
if (r.getSumquantity() == 0) {
r.setShowThl("总数为0");
} else {
double percentage =(double)r.getPicknum()/r.getSumquantity();
String result = String.format("%.2f", percentage);
r.setShowThl(result);
}
return r;
}
public PageResult<SalesAnalysisResp> getListPage(SalesAnalysisReq req) {
IPage<SalesAnalysisResp> mpPage = MyBatisUtils.buildPage(req);
long total = salesAnalysisMapper.GetCount(req);
System.out.println("符合条件的客户总数:"+String.valueOf(total));
System.out.println("符合条件的客户总数:" + String.valueOf(total));
int start = (req.getPageNo() - 1) * req.getPageSize();
int size = req.getPageSize();
req.setSize(size);
req.setStart(start);
//订单状态
List<DictDataRespDTO> dic_order_status =
dictDataApi.getDictDatas("order_status");
Map<String, String> map_order_status = new HashMap<>();
for (DictDataRespDTO d : dic_order_status
) {
map_order_status.put(d.getValue(), d.getLabel());
}
List<SalesAnalysisResp> list = salesAnalysisMapper.getListPage(req);
int nPm = req.getStart() + 1;
String sTemp = "";
for (SalesAnalysisResp r : list) {
r.setPx(nPm);
nPm++;
//订单状态
r.setStatusName(map_order_status.get(r.getStatus()));
String sType = "";
if (r.getOrdertype() == 2) {
//是重货,非泡货
sType = "是/否";
} else if (r.getOrdertype() == 3) {
sType = "否/是";
} else if (r.getOrdertype() == 1) {
sType = "普货";
}
r.setOrdertypeShow(sType);
//业务数据逻辑运算
r = calBis(r);
if (r.getUseweightunit() == null) r.setUseweightunit("无");
if (r.getUsevolumeunit() == null) r.setUsevolumeunit("无");
r.setZpUnitShow(r.getUseweightunit() + "/" + r.getUsevolumeunit());
}
return new PageResult<>(list, total, mpPage.getSize(),
req.getPageNo(), (total + mpPage.getSize() - 1) / mpPage.getSize());
......
package cn.iocoder.yudao.module.delivery.service.Impl;
import cn.iocoder.yudao.module.delivery.entity.SalesReportReq;
import cn.iocoder.yudao.module.delivery.entity.SalesReportResp;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.delivery.entity.*;
import cn.iocoder.yudao.module.delivery.mapper.EmployeeMapper;
import cn.iocoder.yudao.module.delivery.mapper.SalesReportMapper;
import cn.iocoder.yudao.module.delivery.service.SalesReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/*
销售看板统计报表
lanbm 2024-04-01 add
......@@ -19,13 +28,248 @@ public class SalesReportImpl implements SalesReportService {
private SalesReportMapper salesReportMapper;
public SalesReportResp SalesReportCount(SalesReportReq Req) {
return salesReportMapper.SalesReportCount(Req);
public List<SalesReportRespShow> SalesReportCount(SalesReportReq Req) {
Req = getReq(Req);
//String jsonStr = JsonUtils.toJsonString(Req);
//JsonUtils.SaveLog(jsonStr);
//当前数据
SalesReportReq ReqCur = Req;
//对比数据
SalesReportReq ReqLast = getReqTb(Req);
List<SalesReportRespShow> listResult = new ArrayList<>();
SalesReportResp Resp = salesReportMapper.SalesReportCount(ReqCur);
SalesReportResp RespLast = salesReportMapper.SalesReportCount(ReqLast);
//总值
SalesReportRespShow all = new SalesReportRespShow();
if (Resp.getAllsumvolume() == null ||
Resp.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0
) {
all.setSumAll(new BigDecimal(0));
} else {
all.setSumAll(Resp.getAllsumvolume());
}
if (RespLast.getAllsumvolume() == null ||
RespLast.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) {
all.setSumAllTb(new BigDecimal(0));
} else {
all.setSumAllTb(RespLast.getAllsumvolume());
}
String sTemp = "";
if (RespLast.getAllsumvolume() == null ||
RespLast.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) {
sTemp = "同期值为0";
} else {
sTemp = getPercentage(RespLast.getAllsumvolume().subtract(Resp.getAllsumvolume()),
Resp.getAllsumvolume());
}
all.setTbShow(sTemp);
//海运拼柜
SalesReportRespShow all1 = new SalesReportRespShow();
all1.setSumAll(Resp.getSumvolume1());
all1.setSumAllTb(RespLast.getSumvolume1());
if (RespLast.getSumvolume1() == null ||
RespLast.getSumvolume1().compareTo(BigDecimal.ZERO) == 0) {
sTemp = "同期值为0";
} else {
sTemp = getPercentage(RespLast.getSumvolume1().subtract(Resp.getSumvolume1()),
Resp.getSumvolume1());
}
all1.setTbShow(sTemp);
//专线空运
SalesReportRespShow all3 = new SalesReportRespShow();
if (Resp.getSumweight3() == null ||
RespLast.getSumweight3().compareTo(BigDecimal.ZERO) == 0) {
all3.setSumAll(new BigDecimal(0));
} else {
all3.setSumAll(Resp.getSumweight3());
}
if (RespLast.getSumweight3() == null ||
RespLast.getSumweight3().compareTo(BigDecimal.ZERO) == 0) {
all3.setSumAllTb(new BigDecimal(0));
} else {
all3.setSumAllTb(RespLast.getSumweight3());
}
if (RespLast.getSumweight3() == null ||
RespLast.getSumweight3().compareTo(BigDecimal.ZERO) == 0) {
sTemp = "同期值为0";
} else {
sTemp = getPercentage(RespLast.getSumweight3().subtract(Resp.getSumweight3()),
Resp.getSumweight3());
}
all3.setTbShow(sTemp);
listResult.add(all);
listResult.add(all1);
listResult.add(all3);
return listResult;
}
/*
获取首次成交统计数据 lanbm 2024-05-09 add
*/
public SalesReportCusTarget FirstCustomerCount(SalesReportReq Req) {
Req = getReq(Req);
//String jsonStr = JsonUtils.toJsonString(Req);
//JsonUtils.SaveLog(jsonStr);
//当前数据
SalesReportReq ReqCur = Req;
//对比数据
SalesReportReq ReqLast = getReqTb(Req);
SalesReportCusTarget objResult = new SalesReportCusTarget();
int nR = salesReportMapper.FirstCustomerCount(ReqCur);
int nRTb = salesReportMapper.FirstCustomerCount(ReqLast);
String sTemp = "";
if (nRTb == 0) {
sTemp = "同期值为0";
} else {
sTemp = getPercentage(new BigDecimal(nR - nRTb), new BigDecimal(nRTb));
}
objResult.setTbShow(sTemp);
return objResult;
}
public int FirstCustomerCount(SalesReportReq Req) {
return salesReportMapper.FirstCustomerCount(Req);
/*
根据查询参数获取同比查询参数 lanbm 2024-05-09 add
*/
private SalesReportReq getReqTb(SalesReportReq Req) {
SalesReportReq ReqLast = new SalesReportReq();
ReqLast.setSDate(Req.getSDuiBiDate());
ReqLast.setEDate(Req.getEDuiBiDate());
ReqLast.setCurYear(Req.getDuibiYear());
ReqLast.setDeptid(Req.getDeptid());
ReqLast.setSalesmanid(Req.getSalesmanid());
return ReqLast;
}
/*
统计一段时间内客户成交数目,出重客户
lanbm 2024-05-09 add
*/
public SalesReportCusTarget CustomerTargetCount(SalesReportReq Req) {
Req = getReq(Req);
//String jsonStr = JsonUtils.toJsonString(Req);
//JsonUtils.SaveLog(jsonStr);
//当前数据
SalesReportReq ReqCur = Req;
//对比数据
SalesReportReq ReqLast = getReqTb(Req);
SalesReportCusTarget objResult = new SalesReportCusTarget();
int nR = salesReportMapper.CustomerTargetCount(Req);
int nRTb = salesReportMapper.CustomerTargetCount(ReqLast);
String sTemp = "";
if (nRTb == 0) {
sTemp = "同期值为0";
} else {
sTemp = getPercentage(new BigDecimal(nR - nRTb), new BigDecimal(nRTb));
}
objResult.setTbShow(sTemp);
return objResult;
}
/*
格式化BigDecimal为字符串,保留两位小数
lanbm 2024-04-10 add
*/
private String format(BigDecimal value) {
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(2);
numberFormat.setMaximumFractionDigits(2);
return numberFormat.format(value.doubleValue());
}
/*
计算百分比
lanbm 2024-04-10 add
*/
private String getPercentage(BigDecimal part, BigDecimal total) {
BigDecimal percentage = part.divide(total, 5,
BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
// 输出百分比
String sR = format(percentage) + "%";
return sR;
}
private String getCurDate() {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String currentDate = sdf.format(date);
return currentDate;
}
private int getCurYear() {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
return year;
}
/*
获取某年某月的最后一天 lanbm 2024-04-16 add
*/
private int getLastDay(int year, int month) {
YearMonth yearMonth = YearMonth.of(year, month);
int lastDay = yearMonth.lengthOfMonth();
return lastDay;
}
/*
对查询日期做初始化处理 lanbm 2024-05-09 add
*/
private SalesReportReq getReq(SalesReportReq Req) {
int y = getCurYear();
if (Req.getDuibiYear() == null) {
Req.setDuibiYear(String.valueOf(y - 1));
}
if (Req.getSDate() == null) {
Req.setCurYear(String.valueOf(y));
Req.setSDate(String.valueOf(y) + "-01-01");
Req.setSDuiBiDate(Req.getDuibiYear() + "-01-01");
} else {
//2024-03
String sT = Req.getSDate();
Req.setSDate(sT + "-01");
String s = sT.substring(5, 7);
Req.setSDuiBiDate(Req.getDuibiYear() + "-" + s + "-01");
Req.setCurYear(sT.substring(0, 4));
}
if (Req.getEDate() == null) {
Req.setEDate(getCurDate());
String s = Req.getEDate().substring(5, 7);
int lastDay = getLastDay(Integer.parseInt(Req.getDuibiYear()), Integer.parseInt(s));
Req.setEDuiBiDate(Req.getDuibiYear() + "-" + s + "-" + String.valueOf(lastDay));
} else {
String sE = Req.getEDate();
String sY = sE.substring(0, 4);
String s = sE.substring(5, 7);
int lastDay = getLastDay(Integer.parseInt(sY), Integer.parseInt(s));
Req.setEDate(sE + "-" + String.valueOf(lastDay));
lastDay = getLastDay(Integer.parseInt(Req.getDuibiYear()), Integer.parseInt(s));
Req.setEDuiBiDate(Req.getDuibiYear() + "-" + s + "-" + String.valueOf(lastDay));
}
return Req;
}
}
package cn.iocoder.yudao.module.delivery.service.Impl;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.orderdata.StatisticalSummary;
import cn.iocoder.yudao.module.delivery.mapper.SalesReportMapper;
import cn.iocoder.yudao.module.delivery.mapper.StatisticalSummaryMapper;
import cn.iocoder.yudao.module.delivery.service.StatisticalSummaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("StatisticalSummaryImpl")
public class StatisticalSummaryImpl implements StatisticalSummaryService {
@Autowired
private StatisticalSummaryMapper statisticalSummaryMapper;
public StatisticalSummary GetStatisticalSummary(SalesAnalysisReq req) {
return statisticalSummaryMapper.GetStatisticalSummary(req);
}
}
package cn.iocoder.yudao.module.delivery.service;
import cn.iocoder.yudao.framework.apollo.core.event.Customer.ReceiveCustomerCalTypeEvent;
//import cn.iocoder.yudao.module.delivery.entity.orderdata.OrderExt;
/*
订单相关的业务逻辑扩展 lanbm 2024-05-07 add
判断订单发货方客户活收货方客户是否有已入仓订单
*/
public interface OrderServiceExt {
/*
客户为发货方是否有订单
*/
int IsHavingOrderConsignor(ReceiveCustomerCalTypeEvent event);
/*
客户为收货方是否有订单
*/
int IsHavingOrderConsignee(ReceiveCustomerCalTypeEvent event);
/*
上面2个函数废弃不用了,用此函数来判断客户是否已经产生了订单
*/
int IsHavingOrder(ReceiveCustomerCalTypeEvent event);
}
package cn.iocoder.yudao.module.delivery.service;
import cn.iocoder.yudao.module.delivery.entity.SalesReportCusTarget;
import cn.iocoder.yudao.module.delivery.entity.SalesReportReq;
import cn.iocoder.yudao.module.delivery.entity.SalesReportResp;
import cn.iocoder.yudao.module.delivery.entity.SalesReportRespShow;
import java.util.List;
public interface SalesReportService {
SalesReportResp SalesReportCount(SalesReportReq Req);
List<SalesReportRespShow> SalesReportCount(SalesReportReq Req);
SalesReportCusTarget FirstCustomerCount(SalesReportReq Req);
int FirstCustomerCount(SalesReportReq Req);
/*
统计一段时间内客户成交数目,出重客户
lanbm 2024-05-09 add
*/
SalesReportCusTarget CustomerTargetCount(SalesReportReq Req);
}
package cn.iocoder.yudao.module.delivery.service;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.orderdata.StatisticalSummary;
public interface StatisticalSummaryService {
StatisticalSummary GetStatisticalSummary(SalesAnalysisReq req);
}
......@@ -23,7 +23,7 @@
cf.resource_type as cfresourceType,sh.resource_type as shResource_type,
cf.is_new as cfYeJiType,sh.is_new as shYeJitype,
(SELECT sum(ecw_order_pickup.pick_num) FROM ecw_order_pickup
WHERE ( ecw_order_pickup.order_id = c.order_no)) AS picknum,
WHERE ( ecw_order_pickup.order_id = c.order_no)) AS picknum,
(select in_time from ecw_order_warehouse_in where
order_id=c.order_id ORDER BY in_time asc LIMIT 1) as firstInTime
from ecw_order c
......@@ -55,32 +55,118 @@
and c.deleted = 0
<if test="orderNo!=null and orderNo!=''">
<!--订单编号-->
and c.order_no= #{orderNo}
<if test="SearchType1!=null and SearchType1!=''">
<choose>
<when test="SearchType1 =='in'.toString()">
and c.order_no like concat('%',#{orderNo},'%')
</when>
<when test="SearchType1 =='notin'.toString()">
and c.order_no not like concat('%',#{orderNo},'%')
</when>
<when test="SearchType1 =='eq'.toString()">
and c.order_no= #{orderNo}
</when>
<when test="SearchType1 =='noeq'.toString()">
and c.order_no!= #{orderNo}
</when>
<otherwise>
and c.order_no= #{orderNo}
</otherwise>
</choose>
</if>
</if>
<if test="tidanNo!=null and tidanNo!=''">
<!--提单编号-->
and c.tidan_no= #{tidanNo}
<if test="SearchType2!=null and SearchType2!=''">
<choose>
<when test="SearchType2 =='in'.toString()">
and c.tidan_no like concat('%',#{tidanNo},'%')
</when>
<when test="SearchType2 =='notin'.toString()">
and c.tidan_no not like concat('%',#{tidanNo},'%')
</when>
<when test="SearchType2 =='eq'.toString()">
and c.tidan_no= #{tidanNo}
</when>
<when test="SearchType2 =='noeq'.toString()">
and c.tidan_no!= #{tidanNo}
</when>
<otherwise>
and c.tidan_no= #{tidanNo}
</otherwise>
</choose>
</if>
</if>
<if test="fhNumber!=null and fhNumber!=''">
<!--发货人编号-->
and cf.number= #{fhNumber}
<if test="SearchType3!=null and SearchType3!=''">
<choose>
<when test="SearchType3 =='in'.toString()">
and cf.number like concat('%',#{fhNumber},'%')
</when>
<when test="SearchType3 =='notin'.toString()">
and cf.number not like concat('%',#{fhNumber},'%')
</when>
<when test="SearchType3 =='eq'.toString()">
and cf.number= #{fhNumber}
</when>
<when test="SearchType3 =='noeq'.toString()">
and cf.number!= #{fhNumber}
</when>
<otherwise>
and cf.number= #{fhNumber}
</otherwise>
</choose>
</if>
</if>
<if test="shNumber!=null and shNumber!=''">
<!--收货人编号-->
and sh.number= #{shNumber}
<if test="SearchType4!=null and SearchType4!=''">
<choose>
<when test="SearchType4 =='in'.toString()">
and sh.number like concat('%',#{shNumber},'%')
</when>
<when test="SearchType4 =='notin'.toString()">
and sh.number not like concat('%',#{shNumber},'%')
</when>
<when test="SearchType4 =='eq'.toString()">
and sh.number= #{shNumber}
</when>
<when test="SearchType4 =='noeq'.toString()">
and sh.number!= #{shNumber}
</when>
<otherwise>
and sh.number= #{shNumber}
</otherwise>
</choose>
</if>
</if>
<if test="marks!=null and marks!=''">
<!--唛头-->
and c.marks= #{marks}
<if test="SearchType5!=null and SearchType5!=''">
<choose>
<when test="SearchType5 =='in'.toString()">
and c.marks like concat('%',#{marks},'%')
</when>
<when test="SearchType5 =='notin'.toString()">
and c.marks not like concat('%',#{marks},'%')
</when>
<when test="SearchType5 =='eq'.toString()">
and c.marks=#{marks}
</when>
<when test="SearchType5 =='noeq'.toString()">
and c.marks!= #{marks}
</when>
<otherwise>
and c.marks= #{marks}
</otherwise>
</choose>
</if>
</if>
<if test="salesmanId!=null and salesmanId!=''">
<!--客户经理-->
and c.salesman_id= #{salesmanId}
</if>
<if test="status!=null and status!=''">
<!--订单状态-->
and c.status= #{status}
......@@ -89,33 +175,26 @@
<!--运输方式查询条件-->
and c.transport_id= #{transportId}
</if>
<if test="startWarehouseId!=null and startWarehouseId!=''">
<!--始发仓-->
and w.start_warehouse_id= #{startWarehouseId}
</if>
<if test="muDiGuo!=null and muDiGuo!=''">
<!--目的国-->
and w.muDiGuoID= #{muDiGuo}
</if>
<if test="muDiShi!=null and muDiShi!=''">
<!--目的城市-->
and w.muDiShiID= #{muDiShi}
</if>
<if test="dstwarehouseid!=null and dstwarehouseid!=''">
<!--目的仓-->
and w.dst_warehouse_id= #{dstwarehouseid}
</if>
<if test="isCargoControl!=null and isCargoControl!=''">
<!--是否控货-->
<if test="isCargoControl!=null">
<!--是否控货 注意整型值的判断-->
and c.is_cargo_control= #{isCargoControl}
</if>
<if test="zpType!=null and zpType!=''">
<!--重泡货类型-->
and c.order_type= #{zpType}
......@@ -128,24 +207,19 @@
<!--渠道-->
and c.channel_id= #{shippingChannelId}
</if>
<if test="ResourceType!=null and ResourceType!=''">
<!--资源类型-->
and c.channel_id= #{ResourceType}
</if>
<if test="YeJiType!=null and YeJiType!=''">
<!--业绩类型-->
and c.channel_id= #{YeJiType}
</if>
<if test="dateSearch1!=null and dateSearch1!=''
and sdate1!=null and sdate1!=''
and edate2!=null and edate2!=''">
and sdate1!=null and sdate1!='' and edate2!=null and edate2!=''">
<!--订单创建时间-->
and c.create_time BETWEEN #{sdate1} AND #{edate2}
</if>
<if test="dataSearch3!=null and dataSearch3!=''">
<if test="dataSearch1!=null and dataSearch1!=''">
<if test="dataSearch2=null and dataSearch2!=''">
......@@ -175,8 +249,26 @@
<select id="GetCount" resultType="java.lang.Long">
SELECT count(1)
from ecw_order c
SELECT count(1) from ecw_order c
left join (SELECT ewl.id AS line_id,
ew_start.id AS start_warehouse_id,
ew_dest.id AS dst_warehouse_id,ew_start.title_zh AS start_title_zh,
ew_dest.title_zh AS dst_warehouse_name,
r_dest.title_zh as muDiGuo, r_dest.id as muDiGuoID,
r_sdest.title_zh as muDiShi,r_sdest.id as muDiShiID,
ew_start.title_zh AS start_warehouse_name FROM ecw_warehouse_line ewl
LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
left join ecw_region r_dest on ew_dest.guojia=r_dest.id
LEFT JOIN ecw_region r_sdest on ew_dest.shi=r_sdest.id
) w ON w.line_id = c.line_id
left join ecw_channel channel on channel.channel_id =c.channel_id and channel.deleted=0
<!--订单发货人信息-->
left join ecw_order_consignor nor on nor.order_id = c.order_id and nor.deleted=0
left join ecw_customer cf on cf.id=nor.customer_id and cf.deleted=0
<!--订单收货人信息-->
left join ecw_order_consignee nee on nee.order_id = c.order_id and nee.deleted=0
left join ecw_customer sh on sh.id=nee.customer_id and sh.deleted=0
<include refid="WherePage"/>
</select>
......
......@@ -2,33 +2,60 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.delivery.mapper.SalesReportMapper">
<select id="SalesReportCount" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportResp">
SELECT
(
SELECT
sum( sum_volume )
FROM
ecw_order
WHERE
is_del = 0
AND ( transport_id = 1 OR transport_id = 3 )
AND create_time BETWEEN '2023-01-01'
AND '2023-03-31'
) AS allsumvolume,
( SELECT sum( sum_volume ) FROM ecw_order WHERE is_del = 0 AND transport_id = 1 AND create_time BETWEEN '2023-01-01' AND '2023-03-31' ) AS sumvolume1,
( SELECT sum( sum_weight ) FROM ecw_order WHERE is_del = 0 AND transport_id = 3 AND create_time BETWEEN '2023-01-01' AND '2023-03-31' ) AS sumweight3
FROM
DUAL
SELECT (
SELECT sum(sum_volume)
FROM ecw_order
WHERE is_del = 0
AND (transport_id = 1 OR transport_id = 3)
AND create_time BETWEEN '2023-01-01'
AND '2023-03-31'
) AS allsumvolume,
(SELECT sum(sum_volume)
FROM ecw_order
WHERE is_del = 0
AND transport_id = 1
AND create_time BETWEEN '2023-01-01' AND '2023-03-31') AS sumvolume1,
(SELECT sum(sum_weight)
FROM ecw_order
WHERE is_del = 0
AND transport_id = 3
AND create_time BETWEEN '2023-01-01' AND '2023-03-31') AS sumweight3
FROM DUAL
</select>
<!--2024-04-22-->
<select id="FirstCustomerCount" resultType="int">
SELECT count(c.customer_id) as s_customer_id from ecw_order a
left join ecw_order_consignee c on a.order_id=c.order_id
left join ecw_customer cc on cc.id=c.customer_id
where cc.is_new=0 and
a.is_del=0 and a.status>0 and
a.create_time BETWEEN '2023-01-01' AND'2023-01-31'
and a.drawee=2
SELECT count(c.customer_id) as s_customer_id
from ecw_order a
left join ecw_order_consignee c on a.order_id = c.order_id
left join ecw_customer cc on cc.id = c.customer_id
where cc.is_new = 0
and a.is_del = 0
and a.status > 0
and a.create_time BETWEEN '2023-01-01' AND '2023-01-31'
and a.drawee = 2
</select>
<select id="CustomerTargetCount" resultType="int">
<!--根据业绩达成日志来统计-->
SELECT COUNT( DISTINCT customer_id) as countTargrt from ecw_target_log
<where>
deleted=0
<if test="sDate!=null and sDate!='' and
eDate!=null and eDate!=''">
and achievement_time BETWEEN #{sDate} and #{eDate}
</if>
<if test="salesmanid!=null and salesmanid!=''">
<!--客户经理查询条件-->
and user_id= #{salesmanid}
</if>
<if test="deptid!=null and deptid!=''">
<!--部门查询条件-->
and user_id= #{salesmanid}
</if>
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.delivery.mapper.StatisticalSummaryMapper">
<select id="GetStatisticalSummary"
resultType="cn.iocoder.yudao.module.delivery.entity.orderdata.StatisticalSummary">
select c.order_id,
sum(sum_quantity) as sumBox,
sum(if(c.transport_id = 1, sum_volume, 0)) as sumM3,
sum(if(c.transport_id = 3, sum_weight, 0)) as sumKG,
ROUND(sum(IF(c.transport_id = 1,
c.sum_volume / (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'M3' LIMIT 1),
round(c.sum_weight / (SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'KG' LIMIT 1), 2))),
2) as sumV,
sum(if(cf.is_new = 1, sum_quantity, 0)) as sumBoxNew,
sum(if(cf.is_new = 1, if(c.transport_id = 1, sum_volume, 0), 0)) as sumM3New,
sum(if(cf.is_new = 1, if(c.transport_id = 3, sum_weight, 0), 0)) as sumKGNew,
round(sum(if(cf.is_new = 1, IF(c.transport_id = 1, c.sum_volume /
(SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'M3' LIMIT 1),
round(c.sum_weight /
(SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'KG' LIMIT 1),
2)), 0)), 2) as sumVNew,
sum(if(cf.is_new = 0, sum_quantity, 0)) as sumBoxOld,
sum(if(cf.is_new = 0, if(c.transport_id = 1, sum_volume, 0), 0)) as sumM3Old,
sum(if(cf.is_new = 0, if(c.transport_id = 3, sum_weight, 0), 0)) as sumKGOld,
round(sum(if(cf.is_new = 0, IF(c.transport_id = 1, c.sum_volume /
(SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'M3' LIMIT 1),
round(c.sum_weight /
(SELECT ecw_vz.vz FROM ecw_vz WHERE ecw_vz.fuhao = 'KG' LIMIT 1),
2)), 0)), 2) as sumVOld
from ecw_order c
left join (SELECT ewl.id AS line_id,
ew_start.id AS start_warehouse_id,
ew_dest.id AS dst_warehouse_id,
ew_start.title_zh AS start_title_zh,
ew_dest.title_zh AS dst_warehouse_name,
r_dest.title_zh as muDiGuo,
r_dest.id as muDiGuoID,
r_sdest.title_zh as muDiShi,
r_sdest.id as muDiShiID,
ew_start.title_zh AS start_warehouse_name
FROM ecw_warehouse_line ewl
LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
left join ecw_region r_dest on ew_dest.guojia = r_dest.id
LEFT JOIN ecw_region r_sdest on ew_dest.shi = r_sdest.id
) w ON w.line_id = c.line_id
left join ecw_channel channel on channel.channel_id = c.channel_id and channel.deleted = 0
left join ecw_order_consignor nor on nor.order_id = c.order_id and nor.deleted = 0
left join ecw_customer cf on cf.id = nor.customer_id and cf.deleted = 0
left join ecw_order_consignee nee on nee.order_id = c.order_id and nee.deleted = 0
left join ecw_customer sh on sh.id = nee.customer_id and sh.deleted = 0
<include refid="WherePage"></include>
</select>
<sql id="WherePage">
<where>
and c.deleted = 0
<if test="orderNo!=null and orderNo!=''">
<!--订单编号-->
<if test="SearchType1!=null and SearchType1!=''">
<choose>
<when test="SearchType1 =='in'.toString()">
and c.order_no like concat('%',#{orderNo},'%')
</when>
<when test="SearchType1 =='notin'.toString()">
and c.order_no not like concat('%',#{orderNo},'%')
</when>
<when test="SearchType1 =='eq'.toString()">
and c.order_no= #{orderNo}
</when>
<when test="SearchType1 =='noeq'.toString()">
and c.order_no!= #{orderNo}
</when>
<otherwise>
and c.order_no= #{orderNo}
</otherwise>
</choose>
</if>
</if>
<if test="tidanNo!=null and tidanNo!=''">
<!--提单编号-->
<if test="SearchType2!=null and SearchType2!=''">
<choose>
<when test="SearchType2 =='in'.toString()">
and c.tidan_no like concat('%',#{tidanNo},'%')
</when>
<when test="SearchType2 =='notin'.toString()">
and c.tidan_no not like concat('%',#{tidanNo},'%')
</when>
<when test="SearchType2 =='eq'.toString()">
and c.tidan_no= #{tidanNo}
</when>
<when test="SearchType2 =='noeq'.toString()">
and c.tidan_no!= #{tidanNo}
</when>
<otherwise>
and c.tidan_no= #{tidanNo}
</otherwise>
</choose>
</if>
</if>
<if test="fhNumber!=null and fhNumber!=''">
<!--发货人编号-->
<if test="SearchType3!=null and SearchType3!=''">
<choose>
<when test="SearchType3 =='in'.toString()">
and cf.number like concat('%',#{fhNumber},'%')
</when>
<when test="SearchType3 =='notin'.toString()">
and cf.number not like concat('%',#{fhNumber},'%')
</when>
<when test="SearchType3 =='eq'.toString()">
and cf.number=#{fhNumber}
</when>
<when test="SearchType3 =='noeq'.toString()">
and cf.number!= #{fhNumber}
</when>
<otherwise>
and cf.number= #{fhNumber}
</otherwise>
</choose>
</if>
</if>
<if test="shNumber!=null and shNumber!=''">
<!--收货人编号-->
<if test="SearchType4!=null and SearchType4!=''">
<choose>
<when test="SearchType4 =='in'.toString()">
and sh.number like concat('%',#{shNumber},'%')
</when>
<when test="SearchType4 =='notin'.toString()">
and sh.number not like concat('%',#{shNumber},'%')
</when>
<when test="SearchType4 =='eq'.toString()">
and sh.number= #{shNumber}
</when>
<when test="SearchType4 =='noeq'.toString()">
and sh.number!= #{shNumber}
</when>
<otherwise>
and sh.number= #{shNumber}
</otherwise>
</choose>
</if>
</if>
<if test="marks!=null and marks!=''">
<!--唛头-->
<if test="SearchType5!=null and SearchType5!=''">
<choose>
<when test="SearchType5 =='in'.toString()">
and c.marks like concat('%',#{marks},'%')
</when>
<when test="SearchType5 =='notin'.toString()">
and c.marks not like concat('%',#{marks},'%')
</when>
<when test="SearchType5 =='eq'.toString()">
and c.marks=#{marks}
</when>
<when test="SearchType5 =='noeq'.toString()">
and c.marks!= #{marks}
</when>
<otherwise>
and c.marks= #{marks}
</otherwise>
</choose>
</if>
</if>
<if test="salesmanId!=null and salesmanId!=''">
<!--客户经理-->
and c.salesman_id= #{salesmanId}
</if>
<if test="status!=null and status!=''">
<!--订单状态-->
and c.status= #{status}
</if>
<if test="transportId!=null and transportId!=''">
<!--运输方式查询条件-->
and c.transport_id= #{transportId}
</if>
<if test="startWarehouseId!=null and startWarehouseId!=''">
<!--始发仓-->
and w.start_warehouse_id= #{startWarehouseId}
</if>
<if test="muDiGuo!=null and muDiGuo!=''">
<!--目的国-->
and w.muDiGuoID= #{muDiGuo}
</if>
<if test="muDiShi!=null and muDiShi!=''">
<!--目的城市-->
and w.muDiShiID= #{muDiShi}
</if>
<if test="dstwarehouseid!=null and dstwarehouseid!=''">
<!--目的仓-->
and w.dst_warehouse_id= #{dstwarehouseid}
</if>
<if test="isCargoControl!=null">
<!--是否控货 注意整型值的判断-->
and c.is_cargo_control= #{isCargoControl}
</if>
<if test="zpType!=null and zpType!=''">
<!--重泡货类型-->
and c.order_type= #{zpType}
</if>
<if test="drawee!=null and drawee!=''">
<!--付款方-->
and c.drawee= #{drawee}
</if>
<if test="shippingChannelId!=null and shippingChannelId!=''">
<!--渠道-->
and c.channel_id= #{shippingChannelId}
</if>
<if test="ResourceType!=null and ResourceType!=''">
<!--资源类型-->
and c.channel_id= #{ResourceType}
</if>
<if test="YeJiType!=null and YeJiType!=''">
<!--业绩类型-->
and c.channel_id= #{YeJiType}
</if>
<if test="dateSearch1!=null and dateSearch1!=''
and sdate1!=null and sdate1!='' and edate2!=null and edate2!=''">
<!--订单创建时间-->
and c.create_time BETWEEN #{sdate1} AND #{edate2}
</if>
<if test="dataSearch3!=null and dataSearch3!=''">
<if test="dataSearch1!=null and dataSearch1!=''">
<if test="dataSearch2=null and dataSearch2!=''">
<!--数据筛选-->
<choose>
<when test="dataSearch1 =='1'.toString()">
<!--入仓箱数-->
</when>
<when test="dataSearch1 =='2'.toString()">
<!--入仓体积-->
</when>
<when test="dataSearch1 =='3'.toString()">
<!--入仓重量-->
</when>
<when test="dataSearch1 =='3'.toString()">
<!--重/泡标准-->
</when>
<when test="dataSearch1 =='3'.toString()">
<!--提货率-->
</when>
</choose>
</if>
</if>
</if>
</where>
</sql>
</mapper>
......@@ -5994,4 +5994,22 @@ public interface OrderMapper extends AbstractMapper<OrderDO> {
@Update("update ecw_order set sum_cartons_num_prev_packed = sum_num, sum_quantity_all_prev_packed = sum_quantity, sum_weight_prev_packed = sum_weight, sum_volume_prev_packed = sum_volume where order_id = #{orderId}")
void updateSumDataPrevPacked(@Param("orderId") Long orderId);
/*
更新订单业绩类型 yeji_type,yeji_create_date,cal_v_value
lanbm 2024-05-13 add
*/
@Update("update ecw_order set yeji_type=#{yejiType} where order_id = #{orderId}")
void UpdateOrderYeJiType(@Param("orderId") Long orderId,int yejiType);
/*
更新订单V值 lanbm 2024-05-13 add
yeji_create_date 业绩产生时间
简单的SQL语句用SQL注解来写比较方便
*/
@Update("update ecw_order set cal_v_value=#{yejiType},yeji_create_date=#{yejiCreateDate} where order_id = #{orderId}")
void UpdateOrderVValue(@Param("orderId") Long orderId,BigDecimal calVvalue,Date
yejiCreateDate);
}
......@@ -11,8 +11,10 @@ import cn.iocoder.yudao.module.order.vo.order.OrderUpdateReqVO;
import cn.iocoder.yudao.module.order.vo.order.OrderWarehouseInVO;
import cn.iocoder.yudao.module.product.dto.FeeDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.List;
......@@ -351,4 +353,21 @@ public interface OrderService extends IService<OrderDO> {
void updateSumDataPrevPacked(Long orderId);
Long getOrderIdByOrderNo( String orderNo);
/*
更新订单业绩类型 yeji_type,yeji_create_date,cal_v_value
lanbm 2024-05-13 add
yejiType 0是老客户业界,1 是新客户业绩
*/
void UpdateOrderYeJiType(Long orderId,int yejiType);
/*
更新订单V值 lanbm 2024-05-13 add
yeji_create_date 业绩产生时间
*/
void UpdateOrderVValue( Long orderId, BigDecimal calVvalue, Date
yejiCreateDate);
}
......@@ -5,6 +5,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.dto.OrderDto;
import cn.iocoder.yudao.framework.apollo.core.event.*;
//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.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.util.bigDecimal.BigDecimalUtils;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
......@@ -220,7 +222,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
throw exception(ORDER_DELIVERY_DATE_NOT_NULL);
}
}
if (Objects.equals(TransportTypeShortEnum.SEA_CONTAINER.getValue(), createReqVO.getTransportId()) || Objects.equals(TransportTypeShortEnum.MARINE_CONTAINER.getValue(), createReqVO.getTransportId())) {
if (Objects.equals(TransportTypeShortEnum.SEA_CONTAINER.getValue(),
createReqVO.getTransportId()) || Objects.equals(TransportTypeShortEnum.MARINE_CONTAINER.getValue(), createReqVO.getTransportId())) {
// 非空运订单,对前端传值的空运参数做格式化处理
createReqVO.setPortDestCustomsClear(0);
createReqVO.setDeliveryWay(0);
......@@ -416,6 +419,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 创建订单操作日志
orderBusinessService.addOrderOperateLog(order.getOrderId(), "新建订单", null);
//lanbm 2024-04-13 修改,在创建完订单号,计算订单业绩类型
/*
CalculateOrderYeJiTypeEvent even = new CalculateOrderYeJiTypeEvent();
even.setOrderId(order.getOrderId());
applicationContext.publishEvent(even);
*/
// 返回
return order;
}
......@@ -1534,7 +1543,24 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderGuanlianService.deleteRelationByOrderId(updateReqVO.getOrderId());
}
// 更新订单操作日志
orderBusinessService.addOrderOperateLog(updateObj.getOrderId(), "编辑订单", null);
orderBusinessService.addOrderOperateLog(updateObj.getOrderId(),
"编辑订单", null);
//lanbm 2024-04-13 修改,在创建完订单号,计算订单业绩类型
/* Long orderId = updateReqVO.getOrderId();
CalculateOrderYeJiTypeEvent even = new CalculateOrderYeJiTypeEvent();
even.setOrderId(orderId);
applicationContext.publishEvent(even);
*/
//end lanbm 2024-04-13 修改,在创建完订单号,计算订单业绩类型
//入仓完成,计算V值 lanbm 2024-05-13 add
/*
CalculateOrderVValueEvent event=new CalculateOrderVValueEvent();
event.setOrderId(updateObj.getOrderId());
applicationContext.publishEvent(event);*/
//end 入仓完成,计算V值 lanbm 2024-05-13 add
}
......@@ -5899,9 +5925,29 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
public void updateSumDataPrevPacked(Long orderId) {
orderMapper.updateSumDataPrevPacked(orderId);
}
@Override
public Long getOrderIdByOrderNo(String orderNo){
public Long getOrderIdByOrderNo(String orderNo) {
return orderMapper.getOrderIdByOrderNo(orderNo);
}
/*
更新订单业绩类型 yeji_type,yeji_create_date,cal_v_value
lanbm 2024-05-13 add
yejiType 0是老客户业界,1 是新客户业绩
*/
public void UpdateOrderYeJiType(Long orderId, int yejiType) {
orderMapper.UpdateOrderYeJiType(orderId, yejiType);
}
/*
更新订单V值 lanbm 2024-05-13 add
yeji_create_date 业绩产生时间,方便报表统计
*/
public void UpdateOrderVValue(Long orderId, BigDecimal calVvalue, Date
yejiCreateDate) {
orderMapper.UpdateOrderVValue(orderId,calVvalue,yejiCreateDate);
}
}
......@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.BoxCheckOrderSchedulingEvent;
//import cn.iocoder.yudao.framework.apollo.core.event.Order.CalculateOrderVValueEvent;
import cn.iocoder.yudao.framework.apollo.core.event.QueryChannelInfoEvent;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
......@@ -1144,6 +1145,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderDO.setSumVolume(volumeSum);
orderDO.setSumNum(numSum);
// 自定义体积
// orderDO.setCustomSumVolume(finishReqVO.getSumVolume());
// 自定义重量
......@@ -1185,8 +1187,12 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
}
// 更新订单状态
Integer result = orderService.updateStatus(orderId, orderDO.getOrderNo(), OrderStatusEnum.IN_WAREHOUSE.getValue(), null,
OrderWarehouseInStatusEnum.warehouse_finished.getValue(), null, null, null, false);
Integer result = orderService.updateStatus(orderId,
orderDO.getOrderNo(),
OrderStatusEnum.IN_WAREHOUSE.getValue(), null,
OrderWarehouseInStatusEnum.warehouse_finished.getValue(),
null, null,
null, false);
if (!isSplitOrderChildren && isNotRollbackIn) {
// 生成预付异常
......@@ -1234,7 +1240,8 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
} else if (exceptionNum == 1) {
// 由多个异常变成1个异常时,需要更新
OrderExceptionDO orderExceptionDO = orderUnProcessExceptionList.get(0);
orderService.updateStatus(orderId, orderDO.getOrderNo(), null, OrderAbnormalStateEnum.keyOf(orderExceptionDO.getOrderExceptionType()).getValue(), null, null, null, null, false);
orderService.updateStatus(orderId, orderDO.getOrderNo(),
null, OrderAbnormalStateEnum.keyOf(orderExceptionDO.getOrderExceptionType()).getValue(), null, null, null, null, false);
}
// 发送短信通知 - 发给发货人/控货人(拆单子订单不需要发) 1、非拆单子订单 2、未发送短信 3、非退场入仓
......@@ -1285,6 +1292,13 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", msg, "");
}
//入仓完成,计算V值 lanbm 2024-05-13 add
/*
CalculateOrderVValueEvent event=new CalculateOrderVValueEvent();
event.setOrderId(orderId);
applicationContext.publishEvent(event);*/
//end 入仓完成,计算V值 lanbm 2024-05-13 add
// 返回是否包含异常
return exceptionNum > 0;
}
......@@ -2000,6 +2014,10 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
return null;
}
/*
发送入仓短信提醒 lanbm 2024-05-04
处理异常添加注释
*/
public void warehouseInSendSms(OrderDO orderDO, boolean isAppend, Date appendInTime) {
if (Boolean.TRUE.equals(orderDO.getHasSendRucangSms()) && !isAppend) {
log.info("warehouseInSendSms入仓短信已发送过,不需要再次发送短信, orderId={}, orderNo={}", orderDO.getOrderId(), orderDO.getOrderNo());
......@@ -2011,6 +2029,8 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
BigDecimal chargeWeight = BigDecimal.ZERO;
BigDecimal chargeQuantity = BigDecimal.ZERO;
for (OrderItemDO item : orderItemDOList) {
//lanbm 2024-05-04 添加短信发送体积数异常问题分析注释
//计价体积和最小计量体积做对比
chargeVolume = chargeVolume.add((Objects.nonNull(item.getChargeVolume()) && item.getChargeVolume().compareTo(item.getMinMeteringVolume()) > 0)
|| item.getChargeVolume().compareTo(BigDecimal.ZERO) == 0 ? item.getChargeVolume() : item.getMinMeteringVolume());
chargeWeight = chargeWeight.add(Objects.nonNull(item.getChargeWeight()) && item.getChargeWeight().compareTo(item.getMinMeteringWeight()) > 0
......
......@@ -126,13 +126,14 @@ public class OrderWarehouseInController {
public CommonResult<Boolean> finishWarehouseIn(@Valid @RequestBody OrderWarehouseInFinishReqVO finishReqVO) {
String redisKey = MessageFormat.format(ORDER_FINISH_WAREHOUSE_IN_KEY, finishReqVO.getOrderId().toString());
Long count = redisHelper.incrBy(redisKey, 1);
if (count > 1){
if (count > 1) {
return error(ORDER_FINISH_WAREHOUSE_IN_REPEAT_COMMIT);
}
boolean hasException = false;
try {
redisHelper.expire(redisKey, 1, TimeUnit.MINUTES);
hasException = orderWarehouseInService.finishWarehouseIn(finishReqVO);
} catch (Exception e) {
throw e;
} finally {
......@@ -307,8 +308,8 @@ public class OrderWarehouseInController {
@PostMapping("/cancel-adjust")
@ApiOperation("调仓-取消调仓(出仓页面的取消调仓)")
public CommonResult<Boolean> cancelAdjust(@Valid @RequestBody OrderWarehouseInAdjustCancelRequestVO cancelApplyReqVO) {
//调仓-撤销
return success(warehouseAdjustService.cancelAdjust(cancelApplyReqVO));
//调仓-撤销
return success(warehouseAdjustService.cancelAdjust(cancelApplyReqVO));
}
......@@ -339,7 +340,6 @@ public class OrderWarehouseInController {
}
@GetMapping("/statistics-first-finished-after-packed/{orderId}")
@ApiOperation("获取打包后的订单首次完成入仓的统计数据")
@ApiImplicitParam(name = "orderId", value = "订单ID", required = true, example = "1024", dataTypeClass = Long.class)
......@@ -348,7 +348,6 @@ public class OrderWarehouseInController {
}
@GetMapping("/get-order-warehouse-in-common-attr-list")
@ApiOperation("获取订单入仓商品明细通用属性集合")
@ApiImplicitParams({
......
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