demand: TMS系统 - 客户管理 - 现金客户-增删改查接口

committer: heyu
This commit is contained in:
aike 2025-12-25 13:55:52 +08:00
parent d6223ab13b
commit 502dccc0c5
19 changed files with 630 additions and 90 deletions

View File

@ -489,6 +489,7 @@ public class EmisCustomerUserController extends EmisBaseController
@PreAuthorize("@ss.hasPermi('emis:emisCustomerUser:monthlyShipmentStat')") @PreAuthorize("@ss.hasPermi('emis:emisCustomerUser:monthlyShipmentStat')")
@GetMapping("/monthlyShipmentStat") @GetMapping("/monthlyShipmentStat")
public TableDataInfo monthlyShipmentStat(EmisWaybill emisWaybill) throws EmisBizError { public TableDataInfo monthlyShipmentStat(EmisWaybill emisWaybill) throws EmisBizError {
emisWaybill.setCustomerType("2");
startPage(); startPage();
// 设置权限参数 // 设置权限参数
setPrivParams(emisWaybill); setPrivParams(emisWaybill);
@ -497,6 +498,21 @@ public class EmisCustomerUserController extends EmisBaseController
return getDataTable(list); return getDataTable(list);
} }
/**
* 查询现金客户出货统计
*/
@PreAuthorize("@ss.hasPermi('emis:emisCustomerUser:moneyShipmentStat')")
@GetMapping("/moneyShipmentStat")
public TableDataInfo moneyShipmentStat(EmisWaybill emisWaybill) throws EmisBizError {
emisWaybill.setCustomerType("1");
startPage();
// 设置权限参数
setPrivParams(emisWaybill);
List<MonthlyCustomerShipmentStatVO> list = emisCustomerUserService
.selectMoneyCustomerShipmentStat(emisWaybill);
return getDataTable(list);
}
/** /**
* 查询月结客户出货明细 * 查询月结客户出货明细
*/ */
@ -517,6 +533,7 @@ public class EmisCustomerUserController extends EmisBaseController
@Log(title = "月结客户出货统计", businessType = BusinessType.EXPORT) @Log(title = "月结客户出货统计", businessType = BusinessType.EXPORT)
@PostMapping("/exportMonthlyShipmentStat") @PostMapping("/exportMonthlyShipmentStat")
public void exportMonthlyShipmentStat(HttpServletResponse response, EmisWaybill emisWaybill) throws EmisBizError { public void exportMonthlyShipmentStat(HttpServletResponse response, EmisWaybill emisWaybill) throws EmisBizError {
emisWaybill.setCustomerType("2");
// 设置权限参数 // 设置权限参数
setPrivParams(emisWaybill); setPrivParams(emisWaybill);
List<MonthlyCustomerShipmentStatVO> list = emisCustomerUserService List<MonthlyCustomerShipmentStatVO> list = emisCustomerUserService
@ -525,6 +542,23 @@ public class EmisCustomerUserController extends EmisBaseController
MonthlyShipmentStatExcelUtil.export(response, list, statType); MonthlyShipmentStatExcelUtil.export(response, list, statType);
} }
/**
* 导出现金客户出货统计
*
*/
@PreAuthorize("@ss.hasPermi('emis:emisCustomerUser:exportMoneyShipmentStat')")
@Log(title = "现金客户出货统计", businessType = BusinessType.EXPORT)
@PostMapping("/exportMoneyShipmentStat")
public void exportMoneyShipmentStat(HttpServletResponse response, EmisWaybill emisWaybill) throws EmisBizError {
emisWaybill.setCustomerType("1");
// 设置权限参数
setPrivParams(emisWaybill);
List<MonthlyCustomerShipmentStatVO> list = emisCustomerUserService
.selectMoneyCustomerShipmentStat(emisWaybill);
int statType = resolveStatType(emisWaybill);
MonthlyShipmentStatExcelUtil.exportMoney(response, list, statType);
}
private int resolveStatType(EmisWaybill emisWaybill) { private int resolveStatType(EmisWaybill emisWaybill) {
if (emisWaybill == null || emisWaybill.getParams() == null) { if (emisWaybill == null || emisWaybill.getParams() == null) {
return 1; return 1;

View File

@ -13,11 +13,15 @@ package com.xdadan.erp.emis.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xdadan.erp.common.annotation.Excel;
import com.xdadan.erp.common.core.domain.BaseEntity; import com.xdadan.erp.common.core.domain.BaseEntity;
import lombok.Data; import com.xdadan.erp.common.core.domain.TreeEntity;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import lombok.Data;
/** /**

View File

@ -13,9 +13,14 @@ package com.xdadan.erp.emis.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xdadan.erp.common.annotation.audit.DataAuditField;
import com.xdadan.erp.common.core.domain.BaseEntity; import com.xdadan.erp.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* @ClassName EmisMoneyUser * @ClassName EmisMoneyUser

View File

@ -12,6 +12,8 @@ package com.xdadan.erp.emis.domain;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
//import com.xdadan.erp.common.annotation.audit.DataAuditFilter; //import com.xdadan.erp.common.annotation.audit.DataAuditFilter;
import com.xdadan.erp.common.annotation.audit.DataAuditField; import com.xdadan.erp.common.annotation.audit.DataAuditField;
@ -737,4 +739,39 @@ public class EmisWaybill extends BaseEntity {
/* 销售主管 */ /* 销售主管 */
private String salesExecutive; private String salesExecutive;
/* 现金客户公司 */
private String moneyUserCompany;
/* 运单表副表 */
@JsonIgnore
private EmisWaybillOther waybillOther;
/**
* 获取运单表副表(后端使用,不做null处理)
* @return EmisWaybillOther
*/
public EmisWaybillOther getWaybillOther() {
return waybillOther;
}
/**
* 设置运单表副表
* @param waybillOther EmisWaybillOther
*/
public void setWaybillOther(EmisWaybillOther waybillOther) {
this.waybillOther = waybillOther;
}
/**
* 获取运单表副表(用于JSON序列化返回前端,如果为null则返回空对象)
* @return EmisWaybillOther
*/
@JsonGetter("waybillOther")
public EmisWaybillOther getWaybillOtherForJson() {
if (waybillOther == null) {
return new EmisWaybillOther();
}
return waybillOther;
}
} }

View File

@ -47,8 +47,23 @@ public class EmisWaybillOther extends BaseEntity {
/* 销售支持 */ /* 销售支持 */
@DataAuditField(fieldComment = "销售支持") @DataAuditField(fieldComment = "销售支持")
private String salesSupport; private String salesSupport;
/* 现金客户ID */
@DataAuditField(fieldComment = "现金客户ID")
private Long moneyUserId;
/* 现金客户公司名称 */
private String moneyCompany;
// /* 回款回款人 */
// private String payee;
// /* 销售联系人 */
// private String salesmen;
} }

View File

@ -11,6 +11,7 @@
package com.xdadan.erp.emis.domain.vo; package com.xdadan.erp.emis.domain.vo;
import com.xdadan.erp.common.annotation.Excel; import com.xdadan.erp.common.annotation.Excel;
import com.xdadan.erp.common.annotation.audit.DataAuditField;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -25,9 +26,15 @@ import java.math.BigDecimal;
public class MonthlyCustomerShipmentStatVO implements Serializable { public class MonthlyCustomerShipmentStatVO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/* ID */
private Long id;
/* 客户名称 */ /* 客户名称 */
private String customerName; private String customerName;
/* 公司 */
private String company;
/* 客户编号 */ /* 客户编号 */
private String customerCode; private String customerCode;
@ -193,5 +200,8 @@ public class MonthlyCustomerShipmentStatVO implements Serializable {
/* 首次签约日期 */ /* 首次签约日期 */
private String firstSigningDay; private String firstSigningDay;
/* 创建日期(现金客户导出使用,对应 create_time) */
private String createTime;
} }

View File

@ -34,6 +34,9 @@ public class WaybillOrder implements Serializable {
// 附件清单 // 附件清单
private List<Attachment> attachmentList; private List<Attachment> attachmentList;
/* 运单表副表 */
private EmisWaybillOther waybillOther ;
private List<DeclareGoods> declareGoodsList; private List<DeclareGoods> declareGoodsList;
private List<DeclareAttachment> declareAttachmentList; private List<DeclareAttachment> declareAttachmentList;
@ -715,6 +718,10 @@ public class WaybillOrder implements Serializable {
voItem.setDestinationPortName(dbWaybill.getDestinationPortName()); voItem.setDestinationPortName(dbWaybill.getDestinationPortName());
voItem.setBoxQuantity(dbWaybill.getBoxQuantity()); voItem.setBoxQuantity(dbWaybill.getBoxQuantity());
// 运单表副表
EmisWaybillOther waybillOther = dbWaybill.getWaybillOther();
voItem.setWaybillOther(waybillOther != null ? waybillOther : new EmisWaybillOther());
return voItem; return voItem;
} }
@ -952,6 +959,14 @@ public class WaybillOrder implements Serializable {
dbWaybill.setDestinationPort(this.getDestinationPort()); dbWaybill.setDestinationPort(this.getDestinationPort());
dbWaybill.setBoxQuantity(this.getBoxQuantity()); dbWaybill.setBoxQuantity(this.getBoxQuantity());
// 运单表副表,仅传递需要更新的字段
if (this.getWaybillOther() != null) {
EmisWaybillOther waybillOther = new EmisWaybillOther();
waybillOther.setMoneyUserId(this.getWaybillOther().getMoneyUserId());
waybillOther.setSalesSupport(this.getWaybillOther().getSalesSupport());
dbWaybill.setWaybillOther(waybillOther);
}
return dbWaybill; return dbWaybill;
} }

View File

@ -10,12 +10,10 @@
*/ */
package com.xdadan.erp.emis.mapper; package com.xdadan.erp.emis.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.emis.domain.EmisCustomerUser; import com.xdadan.erp.emis.domain.EmisCustomerUser;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @ClassName EmisCustomerUserMapper * @ClassName EmisCustomerUserMapper
* @Description <p> 快递客户用户 Mapper 接口 </p> * @Description <p> 快递客户用户 Mapper 接口 </p>

View File

@ -10,11 +10,9 @@
*/ */
package com.xdadan.erp.emis.mapper; package com.xdadan.erp.emis.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.emis.domain.EmisMoneyUser; import com.xdadan.erp.emis.domain.EmisMoneyUser;
import java.util.List;
/** /**
* @ClassName EmisMoneyUserMapper * @ClassName EmisMoneyUserMapper
* @Description <p> 现金用户 Mapper 接口 </p> * @Description <p> 现金用户 Mapper 接口 </p>

View File

@ -400,6 +400,22 @@ public interface EmisWaybillMapper extends BaseMapper<EmisWaybill>
*/ */
List<EmisWaybill> selectMonthlyCustomerShipmentDetail(EmisWaybill emisWaybill); List<EmisWaybill> selectMonthlyCustomerShipmentDetail(EmisWaybill emisWaybill);
/**
* 查询现金客户出货统计
*
* @param emisWaybill 查询条件
* @return 统计结果列表
*/
List<MonthlyCustomerShipmentStatVO> selectMoneyCustomerShipmentStat(EmisWaybill emisWaybill);
/**
* 按目的国家查询现金客户出货统计
*
* @param emisWaybill 查询条件
* @return 统计结果列表
*/
List<MonthlyCustomerShipmentStatVO> selectMoneyCustomerShipmentStatByCountry(EmisWaybill emisWaybill);
/** /**
* 跟踪预警:查询未签收且超过指定时间未有扫描记录的运单(分页) * 跟踪预警:查询未签收且超过指定时间未有扫描记录的运单(分页)
* *

View File

@ -3344,7 +3344,7 @@ public class EmisBaseService {
* 产生客户编码 规则: siteCode+ 000000 * 产生客户编码 规则: siteCode+ 000000
* @return * @return
*/ */
private String genCustomerCode(){ public String genCustomerCode(){
Long maxCode=emisCustomerUserMapper.selectMaxCustomerCode(); Long maxCode=emisCustomerUserMapper.selectMaxCustomerCode();
return maxCode.toString(); return maxCode.toString();
} }

View File

@ -9,14 +9,13 @@
*/ */
package com.xdadan.erp.emis.service; package com.xdadan.erp.emis.service;
import com.xdadan.erp.emis.domain.EmisCustomerUser; import java.util.List;
import com.xdadan.erp.emis.domain.EmisWaybill; import com.xdadan.erp.emis.domain.EmisCustomerUser;
import com.xdadan.erp.emis.domain.exception.EmisBizError; import com.xdadan.erp.emis.domain.EmisWaybill;
import com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO; import com.xdadan.erp.emis.domain.exception.EmisBizError;
import com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO;
import java.util.List; /**
/**
* @ClassName EmisCustomerUserService * @ClassName EmisCustomerUserService
* @Description 快递客户用户 * @Description 快递客户用户
* @author linfso * @author linfso
@ -100,6 +99,15 @@ public interface IEmisCustomerUserService
*/ */
public List<MonthlyCustomerShipmentStatVO> selectMonthlyCustomerShipmentStat(EmisWaybill emisWaybill) throws EmisBizError; public List<MonthlyCustomerShipmentStatVO> selectMonthlyCustomerShipmentStat(EmisWaybill emisWaybill) throws EmisBizError;
/**
* 查询现金客户出货统计
*
* @param emisWaybill 查询条件
* @return 统计结果列表
* @throws com.xdadan.erp.emis.domain.exception.EmisBizError 当statType=3或4时,必需的时间参数缺失时抛出异常
*/
public List<MonthlyCustomerShipmentStatVO> selectMoneyCustomerShipmentStat(EmisWaybill emisWaybill) throws EmisBizError;
/** /**
* 查询月结客户出货明细 * 查询月结客户出货明细
* *
@ -118,4 +126,4 @@ public interface IEmisCustomerUserService
* @return 结果 * @return 结果
*/ */
public int batchUpdateMoneyUserId(Long[] ids, Long moneyUserId, String updateBy, String updateSite); public int batchUpdateMoneyUserId(Long[] ids, Long moneyUserId, String updateBy, String updateSite);
} }

View File

@ -9,11 +9,10 @@
*/ */
package com.xdadan.erp.emis.service; package com.xdadan.erp.emis.service;
import java.util.List;
import com.xdadan.erp.emis.domain.EmisMoneyUser; import com.xdadan.erp.emis.domain.EmisMoneyUser;
import com.xdadan.erp.emis.domain.exception.EmisBizError; import com.xdadan.erp.emis.domain.exception.EmisBizError;
import java.util.List;
/** /**
* @ClassName IEmisMoneyUserService * @ClassName IEmisMoneyUserService
* @Description 现金用户 * @Description 现金用户
@ -70,6 +69,3 @@ public interface IEmisMoneyUserService
public int deleteEmisMoneyUserById(Long id); public int deleteEmisMoneyUserById(Long id);
} }

View File

@ -77,6 +77,23 @@ public class MonthlyShipmentStatExcelUtil {
} }
public static void export(HttpServletResponse response, List<MonthlyCustomerShipmentStatVO> dataList, int statType) { public static void export(HttpServletResponse response, List<MonthlyCustomerShipmentStatVO> dataList, int statType) {
exportInternal(response, dataList, statType, false);
}
/**
* 现金客户出货统计导出
*
* 与月结导出的差异:
* - 文件/Sheet 名称:现金客户出货统计
* - 客户名称列取 company 字段
* - 第二列表头由“首次签约日期”改为“创建日期”,取 createTime 字段(对应 create_time)
*/
public static void exportMoney(HttpServletResponse response, List<MonthlyCustomerShipmentStatVO> dataList, int statType) {
exportInternal(response, dataList, statType, true);
}
private static void exportInternal(HttpServletResponse response, List<MonthlyCustomerShipmentStatVO> dataList,
int statType, boolean moneyCustomer) {
boolean transportLayout = statType == 1 || statType == 3; boolean transportLayout = statType == 1 || statType == 3;
boolean compareMode = statType == 3 || statType == 4; boolean compareMode = statType == 3 || statType == 4;
@ -88,9 +105,14 @@ public class MonthlyShipmentStatExcelUtil {
List<MonthlyCustomerShipmentStatVO> exportList = new ArrayList<>(safeList); List<MonthlyCustomerShipmentStatVO> exportList = new ArrayList<>(safeList);
exportList.add(buildTotalRow(safeList)); exportList.add(buildTotalRow(safeList));
String sheetName = moneyCustomer ? "现金客户出货统计" : "月结客户出货统计";
String[] headers = moneyCustomer
? new String[]{"客户名称", "创建日期", "总票数", "总重量", "销售联系人"}
: BASE_HEADERS;
try { try {
SXSSFWorkbook workbook = new SXSSFWorkbook(200); SXSSFWorkbook workbook = new SXSSFWorkbook(200);
Sheet sheet = workbook.createSheet("月结客户出货统计"); Sheet sheet = workbook.createSheet(sheetName);
sheet.createFreezePane(0, 2); sheet.createFreezePane(0, 2);
// styles // styles
@ -106,7 +128,10 @@ public class MonthlyShipmentStatExcelUtil {
Font greenArrowFont = createArrowFont(workbook, IndexedColors.GREEN.getIndex()); Font greenArrowFont = createArrowFont(workbook, IndexedColors.GREEN.getIndex());
Font blueArrowFont = createArrowFont(workbook, IndexedColors.BLUE.getIndex()); Font blueArrowFont = createArrowFont(workbook, IndexedColors.BLUE.getIndex());
createHeader(sheet, transportLayout ? TRANSPORT_GROUPS : COUNTRY_GROUPS, headerStyle); // 样式缓存:避免在对比模式下创建过多样式导致超过Excel样式限制
Map<String, CellStyle> styleCache = new HashMap<>();
createHeader(sheet, headers, transportLayout ? TRANSPORT_GROUPS : COUNTRY_GROUPS, headerStyle);
int dataStartRow = 2; int dataStartRow = 2;
for (int i = 0; i < exportList.size(); i++) { for (int i = 0; i < exportList.size(); i++) {
@ -116,44 +141,49 @@ public class MonthlyShipmentStatExcelUtil {
row.setHeightInPoints(20); row.setHeightInPoints(20);
int col = 0; int col = 0;
col = writeTextCell(row, col, vo.getCustomerName(), totalRow ? totalTextStyle : textStyle); // 客户名称:月结用 customerName;现金用 company
col = writeTextCell(row, col, vo.getFirstSigningDay(), totalRow ? totalTextStyle : textStyle); String customerName = moneyCustomer ? vo.getCompany() : vo.getCustomerName();
String dateValue = moneyCustomer ? vo.getCreateTime() : vo.getFirstSigningDay();
col = writeTextCell(row, col, customerName, totalRow ? totalTextStyle : textStyle);
col = writeTextCell(row, col, dateValue, totalRow ? totalTextStyle : textStyle);
col = writeIntegerCell(row, col, vo.getTotalTickets(), vo.getTotalTicketsCompareFlag(), col = writeIntegerCell(row, col, vo.getTotalTickets(), vo.getTotalTicketsCompareFlag(),
totalRow ? totalNumberStyle : numberStyle, compareMode && !totalRow, workbook, totalRow ? totalNumberStyle : numberStyle, compareMode && !totalRow, workbook,
redArrowFont, greenArrowFont, blueArrowFont); redArrowFont, greenArrowFont, blueArrowFont, styleCache);
col = writeDecimalCell(row, col, vo.getTotalWeight(), vo.getTotalWeightCompareFlag(), col = writeDecimalCell(row, col, vo.getTotalWeight(), vo.getTotalWeightCompareFlag(),
totalRow ? totalDecimalStyle : decimalStyle, compareMode && !totalRow, workbook, totalRow ? totalDecimalStyle : decimalStyle, compareMode && !totalRow, workbook,
redArrowFont, greenArrowFont, blueArrowFont); redArrowFont, greenArrowFont, blueArrowFont, styleCache);
col = writeTextCell(row, col, vo.getSalesmen(), totalRow ? totalTextStyle : textStyle); col = writeTextCell(row, col, vo.getSalesmen(), totalRow ? totalTextStyle : textStyle);
List<MetricGroup> groups = transportLayout ? TRANSPORT_GROUPS : COUNTRY_GROUPS; List<MetricGroup> groups = transportLayout ? TRANSPORT_GROUPS : COUNTRY_GROUPS;
for (MetricGroup group : groups) { for (MetricGroup group : groups) {
col = writeIntegerCell(row, col, group.ticketGetter.apply(vo), group.ticketFlagGetter.apply(vo), col = writeIntegerCell(row, col, group.ticketGetter.apply(vo), group.ticketFlagGetter.apply(vo),
totalRow ? totalNumberStyle : numberStyle, compareMode && !totalRow, workbook, totalRow ? totalNumberStyle : numberStyle, compareMode && !totalRow, workbook,
redArrowFont, greenArrowFont, blueArrowFont); redArrowFont, greenArrowFont, blueArrowFont, styleCache);
col = writeDecimalCell(row, col, group.weightGetter.apply(vo), group.weightFlagGetter.apply(vo), col = writeDecimalCell(row, col, group.weightGetter.apply(vo), group.weightFlagGetter.apply(vo),
totalRow ? totalDecimalStyle : decimalStyle, compareMode && !totalRow, workbook, totalRow ? totalDecimalStyle : decimalStyle, compareMode && !totalRow, workbook,
redArrowFont, greenArrowFont, blueArrowFont); redArrowFont, greenArrowFont, blueArrowFont, styleCache);
} }
} }
autoSize(sheet); autoSize(sheet);
writeToResponse(response, workbook, "月结客户出货统计"); writeToResponse(response, workbook, sheetName);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("导出月结客户出货统计失败:" + e.getMessage(), e); String msg = moneyCustomer ? "导出现金客户出货统计失败:" : "导出月结客户出货统计失败:";
throw new RuntimeException(msg + e.getMessage(), e);
} }
} }
private static void createHeader(Sheet sheet, List<MetricGroup> groups, CellStyle headerStyle) { private static void createHeader(Sheet sheet, String[] baseHeaders, List<MetricGroup> groups, CellStyle headerStyle) {
Row topRow = sheet.createRow(0); Row topRow = sheet.createRow(0);
Row subRow = sheet.createRow(1); Row subRow = sheet.createRow(1);
topRow.setHeightInPoints(22); topRow.setHeightInPoints(22);
subRow.setHeightInPoints(22); subRow.setHeightInPoints(22);
int col = 0; int col = 0;
for (int i = 0; i < BASE_HEADERS.length; i++) { for (int i = 0; i < baseHeaders.length; i++) {
Cell cell = topRow.createCell(col); Cell cell = topRow.createCell(col);
cell.setCellValue(BASE_HEADERS[i]); cell.setCellValue(baseHeaders[i]);
cell.setCellStyle(headerStyle); cell.setCellStyle(headerStyle);
sheet.addMergedRegion(new CellRangeAddress(0, 1, col, col)); sheet.addMergedRegion(new CellRangeAddress(0, 1, col, col));
sheet.setColumnWidth(col, BASE_WIDTHS[i] * 256); sheet.setColumnWidth(col, BASE_WIDTHS[i] * 256);
@ -189,25 +219,25 @@ public class MonthlyShipmentStatExcelUtil {
private static int writeIntegerCell(Row row, int colIndex, Integer value, Integer compareFlag, CellStyle style, private static int writeIntegerCell(Row row, int colIndex, Integer value, Integer compareFlag, CellStyle style,
boolean compareMode, Workbook workbook, Font redArrowFont, boolean compareMode, Workbook workbook, Font redArrowFont,
Font greenArrowFont, Font blueArrowFont) { Font greenArrowFont, Font blueArrowFont, Map<String, CellStyle> styleCache) {
String text = value == null ? "" : value.toString(); String text = value == null ? "" : value.toString();
applyRichText(row.createCell(colIndex), text, compareFlag, style, compareMode, workbook, applyRichText(row.createCell(colIndex), text, compareFlag, style, compareMode, workbook,
redArrowFont, greenArrowFont, blueArrowFont); redArrowFont, greenArrowFont, blueArrowFont, styleCache);
return colIndex + 1; return colIndex + 1;
} }
private static int writeDecimalCell(Row row, int colIndex, BigDecimal value, Integer compareFlag, CellStyle style, private static int writeDecimalCell(Row row, int colIndex, BigDecimal value, Integer compareFlag, CellStyle style,
boolean compareMode, Workbook workbook, Font redArrowFont, boolean compareMode, Workbook workbook, Font redArrowFont,
Font greenArrowFont, Font blueArrowFont) { Font greenArrowFont, Font blueArrowFont, Map<String, CellStyle> styleCache) {
String text = formatDecimal(value); String text = formatDecimal(value);
applyRichText(row.createCell(colIndex), text, compareFlag, style, compareMode, workbook, applyRichText(row.createCell(colIndex), text, compareFlag, style, compareMode, workbook,
redArrowFont, greenArrowFont, blueArrowFont); redArrowFont, greenArrowFont, blueArrowFont, styleCache);
return colIndex + 1; return colIndex + 1;
} }
private static void applyRichText(Cell cell, String valueText, Integer compareFlag, CellStyle style, private static void applyRichText(Cell cell, String valueText, Integer compareFlag, CellStyle style,
boolean compareMode, Workbook workbook, Font redArrowFont, boolean compareMode, Workbook workbook, Font redArrowFont,
Font greenArrowFont, Font blueArrowFont) { Font greenArrowFont, Font blueArrowFont, Map<String, CellStyle> styleCache) {
if (!compareMode) { if (!compareMode) {
cell.setCellStyle(style); cell.setCellStyle(style);
cell.setCellValue(valueText); cell.setCellValue(valueText);
@ -221,10 +251,17 @@ public class MonthlyShipmentStatExcelUtil {
} }
// 为兼容 SXSSFWorkbook,这里不再使用富文本局部着色,而是整格字体着色 // 为兼容 SXSSFWorkbook,这里不再使用富文本局部着色,而是整格字体着色
// 使用样式缓存避免创建过多样式导致超过Excel的64000样式限制
Font arrowFont = arrow.pickFont(redArrowFont, greenArrowFont, blueArrowFont); Font arrowFont = arrow.pickFont(redArrowFont, greenArrowFont, blueArrowFont);
CellStyle coloredStyle = workbook.createCellStyle(); String cacheKey = style.hashCode() + "_" + arrowFont.getColor();
CellStyle coloredStyle = styleCache.get(cacheKey);
if (coloredStyle == null) {
coloredStyle = workbook.createCellStyle();
coloredStyle.cloneStyleFrom(style); coloredStyle.cloneStyleFrom(style);
coloredStyle.setFont(arrowFont); coloredStyle.setFont(arrowFont);
styleCache.put(cacheKey, coloredStyle);
}
String display = (valueText == null || valueText.isEmpty()) String display = (valueText == null || valueText.isEmpty())
? arrow.symbol ? arrow.symbol

View File

@ -170,10 +170,39 @@ public class EmisCustomerUserServiceImpl extends EmisBaseService implements IEmi
// 按目的国家统计 // 按目的国家统计
result = emisWaybillMapper.selectMonthlyCustomerShipmentStatByCountry(emisWaybill); result = emisWaybillMapper.selectMonthlyCustomerShipmentStatByCountry(emisWaybill);
} else if ("3".equals(emisWaybill.getParams().get("statType"))) { } else if ("3".equals(emisWaybill.getParams().get("statType"))) {
// 按运输方式统计,增加与上一个时间段的票数、重量对比标记 // 按运输方式统计,增加与上一个时间段的票数、重量对比标记(根据客户类型自动选择 key)
result = buildShipmentStatWithCompare(emisWaybill, true); result = buildShipmentStatWithCompare(emisWaybill, true);
} else if ("4".equals(emisWaybill.getParams().get("statType"))) { } else if ("4".equals(emisWaybill.getParams().get("statType"))) {
// 按目的国家统计,增加与上一个时间段的票数、重量对比标记 // 按目的国家统计,增加与上一个时间段的票数、重量对比标记(根据客户类型自动选择 key)
result = buildShipmentStatWithCompare(emisWaybill, false);
} else {
result = Collections.emptyList();
}
sortShipmentStat(result);
return result;
}
/**
* 查询现金客户出货统计
*
* @param emisWaybill 查询条件
* @return 统计结果列表
*/
@Override
public List<MonthlyCustomerShipmentStatVO> selectMoneyCustomerShipmentStat(EmisWaybill emisWaybill) throws EmisBizError {
List<MonthlyCustomerShipmentStatVO> result;
if ("1".equals(emisWaybill.getParams().get("statType"))) {
// 按运输方式统计
result = emisWaybillMapper.selectMoneyCustomerShipmentStat(emisWaybill);
} else if ("2".equals(emisWaybill.getParams().get("statType"))) {
// 按目的国家统计
result = emisWaybillMapper.selectMoneyCustomerShipmentStatByCountry(emisWaybill);
} else if ("3".equals(emisWaybill.getParams().get("statType"))) {
// 按运输方式统计,增加与上一个时间段的票数、重量对比标记(根据客户类型自动选择 key)
result = buildShipmentStatWithCompare(emisWaybill, true);
} else if ("4".equals(emisWaybill.getParams().get("statType"))) {
// 按目的国家统计,增加与上一个时间段的票数、重量对比标记(根据客户类型自动选择 key)
result = buildShipmentStatWithCompare(emisWaybill, false); result = buildShipmentStatWithCompare(emisWaybill, false);
} else { } else {
result = Collections.emptyList(); result = Collections.emptyList();
@ -190,7 +219,8 @@ public class EmisCustomerUserServiceImpl extends EmisBaseService implements IEmi
* @param byTransType true=按运输方式统计;false=按目的国家统计 * @param byTransType true=按运输方式统计;false=按目的国家统计
* @throws EmisBizError 当必需的时间参数缺失时抛出异常 * @throws EmisBizError 当必需的时间参数缺失时抛出异常
*/ */
private List<MonthlyCustomerShipmentStatVO> buildShipmentStatWithCompare(EmisWaybill emisWaybill, boolean byTransType) throws EmisBizError { private List<MonthlyCustomerShipmentStatVO> buildShipmentStatWithCompare(EmisWaybill emisWaybill,
boolean byTransType) throws EmisBizError {
if (emisWaybill.getParams() == null) { if (emisWaybill.getParams() == null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "比对参数不能为空"); throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "比对参数不能为空");
} }
@ -222,19 +252,41 @@ public class EmisCustomerUserServiceImpl extends EmisBaseService implements IEmi
String beginCompareDate = ((String) beginCompareObj).trim(); String beginCompareDate = ((String) beginCompareObj).trim();
String endCompareDate = ((String) endCompareObj).trim(); String endCompareDate = ((String) endCompareObj).trim();
// 客户类型:1-普通客户(现金客户);2-月结客户
String customerType = emisWaybill.getCustomerType();
boolean isMoneyCustomer = "1".equals(customerType);
// 当前时间段统计 // 当前时间段统计
List<MonthlyCustomerShipmentStatVO> currentList = byTransType List<MonthlyCustomerShipmentStatVO> currentList;
? emisWaybillMapper.selectMonthlyCustomerShipmentStat(emisWaybill) if (byTransType) {
// 按运输方式统计
currentList = isMoneyCustomer
? emisWaybillMapper.selectMoneyCustomerShipmentStat(emisWaybill)
: emisWaybillMapper.selectMonthlyCustomerShipmentStat(emisWaybill);
} else {
// 按目的国家统计
currentList = isMoneyCustomer
? emisWaybillMapper.selectMoneyCustomerShipmentStatByCountry(emisWaybill)
: emisWaybillMapper.selectMonthlyCustomerShipmentStatByCountry(emisWaybill); : emisWaybillMapper.selectMonthlyCustomerShipmentStatByCountry(emisWaybill);
}
try { try {
// 使用前端传入的对比时间段参数 // 使用前端传入的对比时间段参数
emisWaybill.getParams().put("beginSendDate", beginCompareDate); emisWaybill.getParams().put("beginSendDate", beginCompareDate);
emisWaybill.getParams().put("endSendDate", endCompareDate); emisWaybill.getParams().put("endSendDate", endCompareDate);
List<MonthlyCustomerShipmentStatVO> prevList = byTransType List<MonthlyCustomerShipmentStatVO> prevList;
? emisWaybillMapper.selectMonthlyCustomerShipmentStat(emisWaybill) if (byTransType) {
// 按运输方式统计
prevList = isMoneyCustomer
? emisWaybillMapper.selectMoneyCustomerShipmentStat(emisWaybill)
: emisWaybillMapper.selectMonthlyCustomerShipmentStat(emisWaybill);
} else {
// 按目的国家统计
prevList = isMoneyCustomer
? emisWaybillMapper.selectMoneyCustomerShipmentStatByCountry(emisWaybill)
: emisWaybillMapper.selectMonthlyCustomerShipmentStatByCountry(emisWaybill); : emisWaybillMapper.selectMonthlyCustomerShipmentStatByCountry(emisWaybill);
}
// 还原时间参数 // 还原时间参数
emisWaybill.getParams().put("beginSendDate", beginSendDate); emisWaybill.getParams().put("beginSendDate", beginSendDate);
@ -245,19 +297,27 @@ public class EmisCustomerUserServiceImpl extends EmisBaseService implements IEmi
return currentList; return currentList;
} }
// 以 custNo 作为 key 进行对比 // 根据客户类型选择以 custNo 或 id 作为 key 进行对比:
// - customerType = 2(月结客户):使用 custNo
// - customerType = 1(现金客户):使用 id
Map<String, MonthlyCustomerShipmentStatVO> prevMap = new HashMap<>(); Map<String, MonthlyCustomerShipmentStatVO> prevMap = new HashMap<>();
for (MonthlyCustomerShipmentStatVO item : prevList) { for (MonthlyCustomerShipmentStatVO item : prevList) {
if (item.getCustNo() != null) { String key = isMoneyCustomer
prevMap.put(item.getCustNo(), item); ? (item.getId() != null ? String.valueOf(item.getId()) : null)
: item.getCustNo();
if (key != null) {
prevMap.put(key, item);
} }
} }
for (MonthlyCustomerShipmentStatVO cur : currentList) { for (MonthlyCustomerShipmentStatVO cur : currentList) {
if (cur.getCustNo() == null) { String key = isMoneyCustomer
? (cur.getId() != null ? String.valueOf(cur.getId()) : null)
: cur.getCustNo();
if (key == null) {
continue; continue;
} }
MonthlyCustomerShipmentStatVO prev = prevMap.get(cur.getCustNo()); MonthlyCustomerShipmentStatVO prev = prevMap.get(key);
if (prev == null) { if (prev == null) {
continue; continue;
} }
@ -396,4 +456,5 @@ public class EmisCustomerUserServiceImpl extends EmisBaseService implements IEmi
} }
return emisCustomerUserMapper.batchUpdateMoneyUserId(ids, moneyUserId, updateBy, updateSite); return emisCustomerUserMapper.batchUpdateMoneyUserId(ids, moneyUserId, updateBy, updateSite);
} }
} }

View File

@ -10,16 +10,15 @@
package com.xdadan.erp.emis.service.impl; package com.xdadan.erp.emis.service.impl;
import com.xdadan.erp.emis.domain.EmisMoneyUser; import java.util.List;
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType; import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
import com.xdadan.erp.emis.domain.exception.EmisBizError; import com.xdadan.erp.emis.domain.exception.EmisBizError;
import com.xdadan.erp.emis.mapper.EmisMoneyUserMapper;
import com.xdadan.erp.emis.service.EmisBaseService; import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.service.IEmisMoneyUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.domain.EmisMoneyUser;
import java.util.List; import com.xdadan.erp.emis.mapper.EmisMoneyUserMapper;
import com.xdadan.erp.emis.service.IEmisMoneyUserService;
/** /**
* 现金用户Service业务层处理 * 现金用户Service业务层处理

View File

@ -160,6 +160,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
@Autowired @Autowired
private EmisSalesmenRelMapper emisSalesmenRelMapper; private EmisSalesmenRelMapper emisSalesmenRelMapper;
@Autowired
private EmisMoneyUserMapper emisMoneyUserMapper;
/** /**
* 保存或更新运单其他信息副表 * 保存或更新运单其他信息副表
* @param emisWaybillSave * @param emisWaybillSave
@ -169,10 +172,23 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
return; return;
} }
String salesSupport = emisWaybillSave.getSalesSupport();
String billCode = emisWaybillSave.getBillCode(); String billCode = emisWaybillSave.getBillCode();
Long waybillId = emisWaybillSave.getId(); Long waybillId = emisWaybillSave.getId();
// 从waybillOther中获取moneyUserId
Long moneyUserId = null;
String salesSupport = null;
if (emisWaybillSave.getWaybillOther() != null) {
moneyUserId = emisWaybillSave.getWaybillOther().getMoneyUserId();
salesSupport = emisWaybillSave.getWaybillOther().getSalesSupport();
if (moneyUserId == null) {
moneyUserId = 0L;
}
if (salesSupport == null) {
salesSupport ="";
}
}
// 查询是否已存在 // 查询是否已存在
EmisWaybillOther existing = emisWaybillOtherMapper.selectEmisWaybillOtherByWaybillId(waybillId); EmisWaybillOther existing = emisWaybillOtherMapper.selectEmisWaybillOtherByWaybillId(waybillId);
@ -180,6 +196,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
// 更新 // 更新
existing.setSalesSupport(salesSupport); existing.setSalesSupport(salesSupport);
existing.setBillCode(billCode); existing.setBillCode(billCode);
existing.setMoneyUserId(moneyUserId);
existing.preUpdate(); existing.preUpdate();
emisWaybillOtherMapper.updateEmisWaybillOther(existing); emisWaybillOtherMapper.updateEmisWaybillOther(existing);
} else { } else {
@ -188,6 +205,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
waybillOtherEntity.setWaybillId(waybillId); waybillOtherEntity.setWaybillId(waybillId);
waybillOtherEntity.setBillCode(billCode); waybillOtherEntity.setBillCode(billCode);
waybillOtherEntity.setSalesSupport(salesSupport); waybillOtherEntity.setSalesSupport(salesSupport);
waybillOtherEntity.setMoneyUserId(moneyUserId);
waybillOtherEntity.preInsert(); waybillOtherEntity.preInsert();
emisWaybillOtherMapper.insertEmisWaybillOther(waybillOtherEntity); emisWaybillOtherMapper.insertEmisWaybillOther(waybillOtherEntity);
} }
@ -1112,6 +1130,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
emisWaybillSave.setCustNo(emisCustomerUser.getMonthlyPayCode()); emisWaybillSave.setCustNo(emisCustomerUser.getMonthlyPayCode());
emisWaybillSave.setPayee(emisCustomerUser.getPayee()); emisWaybillSave.setPayee(emisCustomerUser.getPayee());
emisWaybillSave.setSalesmen(emisCustomerUser.getSalesmen()); emisWaybillSave.setSalesmen(emisCustomerUser.getSalesmen());
EmisWaybillOther emisWaybillOther = new EmisWaybillOther();
emisWaybillOther.setSalesSupport(emisCustomerUser.getSalesSupport());
emisWaybillSave.setWaybillOther(emisWaybillOther);
}else{ }else{
@ -1126,6 +1147,19 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
if (salesmen == null) { if (salesmen == null) {
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "销售联系人不存在"); throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "销售联系人不存在");
} }
if (StringUtils.isBlank(emisWaybillSave.getMoneyUserCompany())) {
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "现金客户名称不能为空");
}
// 根据moneyUserCompany查询现金客户
EmisMoneyUser emisMoneyUser = emisMoneyUserMapper.selectEmisMoneyUserByCompany(emisWaybillSave.getMoneyUserCompany());
if (Objects.isNull(emisMoneyUser)) {
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "客户名称不存在");
}
EmisWaybillOther emisWaybillOther = new EmisWaybillOther();
emisWaybillOther.setMoneyUserId(emisMoneyUser.getId());
emisWaybillOther.setSalesSupport(emisMoneyUser.getSalesSupport());
emisWaybillSave.setWaybillOther(emisWaybillOther);
} }

View File

@ -247,6 +247,17 @@
<resultMap id="EmisWaybillResult" extends="BaseEmisWaybillResult" type="EmisWaybill"> <resultMap id="EmisWaybillResult" extends="BaseEmisWaybillResult" type="EmisWaybill">
<!-- 获取订单最后一条扫描记录 --> <!-- 获取订单最后一条扫描记录 -->
<!-- <association property="lastScanRecord" column="bill_code" select="com.xdadan.erp.emis.mapper.EmisTmsScanRecordMapper.selectLastRecordBaseInfoByBillCode"/>--> <!-- <association property="lastScanRecord" column="bill_code" select="com.xdadan.erp.emis.mapper.EmisTmsScanRecordMapper.selectLastRecordBaseInfoByBillCode"/>-->
<!-- 运单表副表 -->
<association property="waybillOther" javaType="EmisWaybillOther">
<result property="id" column="waybill_other_id"/>
<result property="waybillId" column="waybill_other_waybill_id"/>
<result property="billCode" column="waybill_other_bill_code"/>
<result property="salesSupport" column="waybill_other_sales_support"/>
<result property="moneyUserId" column="waybill_other_money_user_id"/>
<result property="moneyCompany" column="waybill_other_money_company"/>
<!-- <result property="payee" column="waybill_other_payee"/>-->
<!-- <result property="salesmen" column="waybill_other_salesmen"/>-->
</association>
</resultMap> </resultMap>
<!-- 获取运单统计条数--> <!-- 获取运单统计条数-->
@ -341,7 +352,15 @@
a3.phone as customer_phone, a3.phone as customer_phone,
a3.nick_name as customer_nick_name, a3.nick_name as customer_nick_name,
a3.avatar as customer_avatar, a3.avatar as customer_avatar,
COALESCE(wss.sales_support, a4.sales_support) as sales_support, -- COALESCE(wss.sales_support, a4.sales_support) as sales_support,
wss.id as waybill_other_id,
wss.waybill_id as waybill_other_waybill_id,
wss.bill_code as waybill_other_bill_code,
COALESCE(wss.sales_support, mu2.sales_support, a4.sales_support) as waybill_other_sales_support,
COALESCE(wss.money_user_id, a3.money_user_id) as waybill_other_money_user_id,
COALESCE(mu.company, mu2.company) as waybill_other_money_company,
-- COALESCE(mu2.payee, a.payee) as waybill_other_payee,
-- COALESCE(mu2.salesmen, a.salesmen) as waybill_other_salesmen,
p.emp_name as dispatch_man_name,q.site_name as print_site_name, p.emp_name as dispatch_man_name,q.site_name as print_site_name,
r.emp_name as print_man_name, r.emp_name as print_man_name,
@ -394,6 +413,8 @@
left join emis_customer_user a3 on a.customer_code=a3.customer_code and a3.del_flag='0' left join emis_customer_user a3 on a.customer_code=a3.customer_code and a3.del_flag='0'
left join emis_customer_user a4 on a.cust_no=a4.monthly_pay_code and a4.del_flag='0' left join emis_customer_user a4 on a.cust_no=a4.monthly_pay_code and a4.del_flag='0'
left join emis_waybill_other wss on a.id=wss.waybill_id and wss.del_flag='0' left join emis_waybill_other wss on a.id=wss.waybill_id and wss.del_flag='0'
left join emis_money_user mu on wss.money_user_id=mu.id and mu.del_flag='0'
left join emis_money_user mu2 on a3.money_user_id=mu2.id and mu2.del_flag='0'
left join emis_site seaway1 on a.departure_port=seaway1.site_code and seaway1.del_flag='0' left join emis_site seaway1 on a.departure_port=seaway1.site_code and seaway1.del_flag='0'
left join emis_site seaway2 on a.destination_port=seaway2.site_code and seaway2.del_flag='0' left join emis_site seaway2 on a.destination_port=seaway2.site_code and seaway2.del_flag='0'
@ -424,7 +445,8 @@
a.register_site_code, a.register_date, a.register_man_code, a.take_piece_employee_code, a.send_site_code, a.send_center_code, a.register_site_code, a.register_date, a.register_man_code, a.take_piece_employee_code, a.send_site_code, a.send_center_code,
a.send_date, a.dispatch_man_code, a.dispatch_date, a.dispatch_site_code, a.produce_bill_date, a.produce_bill_site_code, a.send_date, a.dispatch_man_code, a.dispatch_date, a.dispatch_site_code, a.produce_bill_date, a.produce_bill_site_code,
a.produce_bill_man_code, a.destination_code, a.destination_province, a.destination_city, a.destination_county, a.produce_bill_man_code, a.destination_code, a.destination_province, a.destination_city, a.destination_county,
a.dispatch_underling_site_code, a.destination_center_code, a.market_man_code, a.payee, a.salesmen, a.operate_employee_code, a.dispatch_underling_site_code, a.destination_center_code, a.market_man_code,
a.operate_employee_code,
a.bl_is_question, a.problem_type, a.problem_cause, a.problem_delay_days, a.bl_message, a.bl_accept_message, a.bl_gen_subbill, a.bl_is_question, a.problem_type, a.problem_cause, a.problem_delay_days, a.bl_message, a.bl_accept_message, a.bl_gen_subbill,
a.bl_sign, a.sign_man, a.sign_man_code, a.sign_site_code, a.sign_date, a.bill_pic_send_rmk, a.bill_pic_dispatch_rmk, a.timezone_offset, a.bl_sign, a.sign_man, a.sign_man_code, a.sign_site_code, a.sign_date, a.bill_pic_send_rmk, a.bill_pic_dispatch_rmk, a.timezone_offset,
a.payment_status, a.payment_date, a.payment_remark, a.order_remark, a.data_from, a.bl_special_goods,a.ext_info, a.payment_status, a.payment_date, a.payment_remark, a.order_remark, a.data_from, a.bl_special_goods,a.ext_info,
@ -445,7 +467,17 @@
a3.phone as customer_phone, a3.phone as customer_phone,
a3.nick_name as customer_nick_name, a3.nick_name as customer_nick_name,
a3.avatar as customer_avatar, a3.avatar as customer_avatar,
COALESCE(wss.sales_support, a4.sales_support) as sales_support , COALESCE(a.payee, mu2.payee) as payee,
COALESCE(a.salesmen, mu2.salesmen) as salesmen,
-- COALESCE(wss.sales_support,mu2.sales_support, a4.sales_support) as sales_support ,
wss.id as waybill_other_id,
wss.waybill_id as waybill_other_waybill_id,
wss.bill_code as waybill_other_bill_code,
COALESCE(wss.sales_support, mu2.sales_support, a4.sales_support) as waybill_other_sales_support,
COALESCE(wss.money_user_id, a3.money_user_id) as waybill_other_money_user_id,
COALESCE(mu.company, mu2.company) as waybill_other_money_company,
-- COALESCE(mu2.payee, a.payee) as waybill_other_payee,
-- COALESCE(mu2.salesmen, a.salesmen) as waybill_other_salesmen,
a3.sales_executive , a3.sales_executive ,
a3.customer_type as customer_type, a3.customer_type as customer_type,
a3.main_user_id , a3.main_user_id ,
@ -501,6 +533,8 @@
left join emis_customer_user a3 on a.customer_code=a3.customer_code and a3.del_flag='0' left join emis_customer_user a3 on a.customer_code=a3.customer_code and a3.del_flag='0'
left join emis_customer_user a4 on a.cust_no=a4.monthly_pay_code and a4.del_flag='0' left join emis_customer_user a4 on a.cust_no=a4.monthly_pay_code and a4.del_flag='0'
left join emis_waybill_other wss on a.id=wss.waybill_id and wss.del_flag='0' left join emis_waybill_other wss on a.id=wss.waybill_id and wss.del_flag='0'
left join emis_money_user mu on wss.money_user_id=mu.id and mu.del_flag='0'
left join emis_money_user mu2 on a3.money_user_id=mu2.id and mu2.del_flag='0'
left join emis_site seaway1 on a.departure_port=seaway1.site_code and seaway1.del_flag='0' left join emis_site seaway1 on a.departure_port=seaway1.site_code and seaway1.del_flag='0'
left join emis_site seaway2 on a.destination_port=seaway2.site_code and seaway2.del_flag='0' left join emis_site seaway2 on a.destination_port=seaway2.site_code and seaway2.del_flag='0'
left join emis_site start on a.start_site_code=start.site_code and start.del_flag='0' left join emis_site start on a.start_site_code=start.site_code and start.del_flag='0'
@ -4676,6 +4710,7 @@
<!-- 查询月结客户出货统计 --> <!-- 查询月结客户出货统计 -->
<select id="selectMonthlyCustomerShipmentStat" parameterType="EmisWaybill" resultType="com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO"> <select id="selectMonthlyCustomerShipmentStat" parameterType="EmisWaybill" resultType="com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO">
SELECT SELECT
cu.id AS id,
cu.customer_code AS customerCode, cu.customer_code AS customerCode,
cu.customer_name AS customerName, cu.customer_name AS customerName,
cu.monthly_pay_code AS custNo, cu.monthly_pay_code AS custNo,
@ -4781,6 +4816,7 @@
<!-- 按目的国家查询月结客户出货统计 --> <!-- 按目的国家查询月结客户出货统计 -->
<select id="selectMonthlyCustomerShipmentStatByCountry" parameterType="EmisWaybill" resultType="com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO"> <select id="selectMonthlyCustomerShipmentStatByCountry" parameterType="EmisWaybill" resultType="com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO">
SELECT SELECT
cu.id AS id,
cu.customer_code AS customerCode, cu.customer_code AS customerCode,
cu.customer_name AS customerName, cu.customer_name AS customerName,
cu.monthly_pay_code AS custNo, cu.monthly_pay_code AS custNo,
@ -4893,8 +4929,6 @@
a.del_flag = '0' a.del_flag = '0'
AND a.order_status !='0' AND a.order_status !='0'
AND a.order_status!='2' AND a.order_status!='2'
AND a.cust_no IS NOT NULL
AND a.cust_no != ''
<!-- 剔除问题件类型为面单删除、出口虚拟单、返货虚拟单的运单 --> <!-- 剔除问题件类型为面单删除、出口虚拟单、返货虚拟单的运单 -->
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM emis_waybill_problem_info ewpi SELECT 1 FROM emis_waybill_problem_info ewpi
@ -4942,6 +4976,10 @@
<if test="salesmen != null and salesmen != ''"> <if test="salesmen != null and salesmen != ''">
AND a4.salesmen LIKE CONCAT('%', #{salesmen}, '%') AND a4.salesmen LIKE CONCAT('%', #{salesmen}, '%')
</if> </if>
<!-- 现金客户ID -->
<if test="params.moneyUserId != null and params.moneyUserId != ''">
AND wss.money_user_id = #{params.moneyUserId}
</if>
<!-- 运输方式筛选 --> <!-- 运输方式筛选 -->
<if test="transType != null and transType != ''"> <if test="transType != null and transType != ''">
<if test="transType == 'other'"> <if test="transType == 'other'">
@ -4993,4 +5031,219 @@
</where> </where>
ORDER BY a.order_date DESC, a.send_date DESC ORDER BY a.order_date DESC, a.send_date DESC
</select> </select>
<!-- 查询现金客户出货统计 -->
<select id="selectMoneyCustomerShipmentStat" parameterType="EmisWaybill" resultType="com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO">
SELECT
mu.id AS id,
a.customer_code AS customerCode,
mu.company AS customerName,
NULL AS custNo,
mu.salesmen AS salesmen,
NULL AS firstSigningDay,
mu.company AS company,
mu.create_time AS createTime,
COUNT(DISTINCT a.bill_code) AS totalTickets,
IFNULL(SUM(a.bill_weight), 0) AS totalWeight,
SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '1' THEN 1 ELSE 0 END) AS expressTickets,
IFNULL(SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '1' THEN a.bill_weight ELSE 0 END), 0) AS expressWeight,
SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '2' THEN 1 ELSE 0 END) AS airTickets,
IFNULL(SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '2' THEN a.bill_weight ELSE 0 END), 0) AS airWeight,
SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type in ('3','5') THEN 1 ELSE 0 END) AS landTickets,
IFNULL(SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type in ('3','5') THEN a.bill_weight ELSE 0 END), 0) AS landWeight,
SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '4' THEN 1 ELSE 0 END) AS seaTickets,
IFNULL(SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '4' THEN a.bill_weight ELSE 0 END), 0) AS seaWeight,
SUM(CASE WHEN a.receive_country = '0086' THEN 1 ELSE 0 END) AS importTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0086' THEN a.bill_weight ELSE 0 END), 0) AS importWeight,
SUM(CASE WHEN a.receive_country != '0086' AND NOT (a.send_country = '0086' AND tl.trans_type IN ('1','2','3','4','5')) THEN 1 ELSE 0 END) AS otherTickets,
IFNULL(SUM(CASE WHEN a.receive_country != '0086' AND NOT (a.send_country = '0086' AND tl.trans_type IN ('1','2','3','4','5')) THEN a.bill_weight ELSE 0 END), 0) AS otherWeight
FROM emis_money_user mu
LEFT JOIN emis_waybill_other ewo ON mu.id = ewo.money_user_id AND ewo.del_flag = '0'
LEFT JOIN emis_waybill a ON ewo.waybill_id = a.id
AND a.del_flag = '0'
AND a.order_status != '0'
AND a.order_status != '2'
<!-- 剔除问题件类型为面单删除、出口虚拟单、返货虚拟单的运单 -->
AND NOT EXISTS (
SELECT 1 FROM emis_waybill_problem_info ewpi
WHERE ewpi.bill_code = a.bill_code
AND ewpi.del_flag = '0'
AND ewpi.problem_type IN (151, 170, 173)
)
<!-- 寄件日期范围 -->
<if test="params.beginSendDate != null and params.beginSendDate != ''">
AND a.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
<!-- 寄件国家 -->
<if test="sendCountry != null and sendCountry != ''">
AND a.send_country = #{sendCountry}
</if>
<!-- 目的国家 -->
<if test="receiveCountry != null and receiveCountry != ''">
<choose>
<when test="receiveCountry == 'other'">
AND a.receive_country NOT IN ('0086','0084','0855','0095','0880','0856','0066')
</when>
<otherwise>
AND a.receive_country = #{receiveCountry}
</otherwise>
</choose>
</if>
LEFT JOIN emis_trans_line tl ON a.trans_line_type = tl.line_code AND tl.del_flag = '0'
<where>
mu.del_flag = '0'
<!-- 客户名称 -->
<if test="moneyUserCompany != null and moneyUserCompany != ''">
AND (mu.company LIKE CONCAT('%', #{moneyUserCompany}, '%') )
</if>
<if test="params.moneyUserId != null and params.moneyUserId != ''">
AND mu.id = #{params.moneyUserId}
</if>
<if test="customerCode != null and customerCode != ''">
AND a.customer_code = #{customerCode}
</if>
<!-- 销售主管 -->
<if test="salesExecutive != null and salesExecutive != ''">
AND mu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%')
</if>
<!-- 销售支持 -->
<if test="salesSupport != null and salesSupport != ''">
AND mu.sales_support LIKE CONCAT('%', #{salesSupport}, '%')
</if>
<!-- 销售联系人 -->
<if test="salesmen != null and salesmen != ''">
AND mu.salesmen LIKE CONCAT('%', #{salesmen}, '%')
</if>
<!-- 权限控制 -->
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
AND (
mu.sales_executive = #{params.privEmpName}
OR mu.sales_support = #{params.privEmpName}
OR mu.salesmen = #{params.privEmpName}
OR mu.salesmen IN (
SELECT salesmen FROM emis_salesmen_rel esr
WHERE esr.del_flag = '0'
AND esr.bl_open = '1'
AND NOW() <![CDATA[ >= ]]> esr.start_date
AND NOW() <![CDATA[ <= ]]> esr.end_date
AND esr.sales_ass = #{params.privEmpName}
)
)
</if>
</where>
GROUP BY mu.id, mu.company
ORDER BY totalWeight DESC, totalTickets DESC, company ASC
</select>
<!-- 按目的国家查询现金客户出货统计 -->
<select id="selectMoneyCustomerShipmentStatByCountry" parameterType="EmisWaybill" resultType="com.xdadan.erp.emis.domain.vo.MonthlyCustomerShipmentStatVO">
SELECT
mu.id AS id,
a.customer_code AS customerCode,
mu.company AS customerName,
NULL AS custNo,
mu.salesmen AS salesmen,
NULL AS firstSigningDay,
mu.company AS company,
mu.create_time AS createTime,
COUNT(DISTINCT a.bill_code) AS totalTickets,
IFNULL(SUM(a.bill_weight), 0) AS totalWeight,
SUM(CASE WHEN a.receive_country = '0086' THEN 1 ELSE 0 END) AS chinaTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0086' THEN a.bill_weight ELSE 0 END), 0) AS chinaWeight,
SUM(CASE WHEN a.receive_country = '0084' THEN 1 ELSE 0 END) AS vietnamTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0084' THEN a.bill_weight ELSE 0 END), 0) AS vietnamWeight,
SUM(CASE WHEN a.receive_country = '0855' THEN 1 ELSE 0 END) AS cambodiaTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0855' THEN a.bill_weight ELSE 0 END), 0) AS cambodiaWeight,
SUM(CASE WHEN a.receive_country = '0095' THEN 1 ELSE 0 END) AS myanmarTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0095' THEN a.bill_weight ELSE 0 END), 0) AS myanmarWeight,
SUM(CASE WHEN a.receive_country = '0880' THEN 1 ELSE 0 END) AS bangladeshTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0880' THEN a.bill_weight ELSE 0 END), 0) AS bangladeshWeight,
SUM(CASE WHEN a.receive_country = '0856' THEN 1 ELSE 0 END) AS laosTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0856' THEN a.bill_weight ELSE 0 END), 0) AS laosWeight,
SUM(CASE WHEN a.receive_country = '0066' THEN 1 ELSE 0 END) AS thailandTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0066' THEN a.bill_weight ELSE 0 END), 0) AS thailandWeight,
SUM(CASE WHEN a.receive_country NOT IN ('0086','0084','0855','0095','0880','0856','0066') THEN 1 ELSE 0 END) AS otherTickets,
IFNULL(SUM(CASE WHEN a.receive_country NOT IN ('0086','0084','0855','0095','0880','0856','0066') THEN a.bill_weight ELSE 0 END), 0) AS otherWeight
FROM emis_money_user mu
LEFT JOIN emis_waybill_other ewo ON mu.id = ewo.money_user_id AND ewo.del_flag = '0'
LEFT JOIN emis_waybill a ON ewo.waybill_id = a.id
AND a.del_flag = '0'
AND a.order_status != '0'
AND a.order_status != '2'
<!-- 剔除问题件类型为面单删除、出口虚拟单、返货虚拟单的运单 -->
AND NOT EXISTS (
SELECT 1 FROM emis_waybill_problem_info ewpi
WHERE ewpi.bill_code = a.bill_code
AND ewpi.del_flag = '0'
AND ewpi.problem_type IN (151, 170, 173)
)
<!-- 寄件日期范围 -->
<if test="params.beginSendDate != null and params.beginSendDate != ''">
AND a.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
<!-- 寄件国家 -->
<if test="sendCountry != null and sendCountry != ''">
AND a.send_country = #{sendCountry}
</if>
<!-- 目的国家 -->
<if test="receiveCountry != null and receiveCountry != ''">
<choose>
<when test="receiveCountry == 'other'">
AND a.receive_country NOT IN ('0086','0084','0855','0095','0880','0856','0066')
</when>
<otherwise>
AND a.receive_country = #{receiveCountry}
</otherwise>
</choose>
</if>
<where>
mu.del_flag = '0'
<!-- 客户名称 -->
<if test="moneyUserCompany != null and moneyUserCompany != ''">
AND (mu.company LIKE CONCAT('%', #{moneyUserCompany}, '%') )
</if>
<if test="customerName != null and customerName != ''">
AND (mu.company LIKE CONCAT('%', #{customerName}, '%') )
</if>
<if test="params.moneyUserId != null and params.moneyUserId != ''">
AND mu.id = #{params.moneyUserId}
</if>
<!-- 销售主管 -->
<if test="salesExecutive != null and salesExecutive != ''">
AND mu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%')
</if>
<!-- 销售支持 -->
<if test="salesSupport != null and salesSupport != ''">
AND mu.sales_support LIKE CONCAT('%', #{salesSupport}, '%')
</if>
<!-- 销售联系人 -->
<if test="salesmen != null and salesmen != ''">
AND mu.salesmen LIKE CONCAT('%', #{salesmen}, '%')
</if>
<!-- 权限控制 -->
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
AND (
mu.sales_executive = #{params.privEmpName}
OR mu.sales_support = #{params.privEmpName}
OR mu.salesmen = #{params.privEmpName}
OR mu.salesmen IN (
SELECT salesmen FROM emis_salesmen_rel esr
WHERE esr.del_flag = '0'
AND esr.bl_open = '1'
AND NOW() <![CDATA[ >= ]]> esr.start_date
AND NOW() <![CDATA[ <= ]]> esr.end_date
AND esr.sales_ass = #{params.privEmpName}
)
)
</if>
</where>
GROUP BY mu.id, mu.company
ORDER BY totalWeight DESC, totalTickets DESC, company ASC
</select>
</mapper> </mapper>

View File

@ -9,27 +9,44 @@
<result property="waybillId" column="waybill_id" /> <result property="waybillId" column="waybill_id" />
<result property="billCode" column="bill_code" /> <result property="billCode" column="bill_code" />
<result property="salesSupport" column="sales_support" /> <result property="salesSupport" column="sales_support" />
<result property="moneyUserId" column="money_user_id" />
<result property="moneyCompany" column="money_company" />
</resultMap> </resultMap>
<sql id="selectEmisWaybillOtherVo"> <sql id="selectEmisWaybillOtherVo">
select id, waybill_id, bill_code, sales_support, del_flag, create_by, create_time, update_by, update_time, create_site, update_site, remark select
from emis_waybill_other a.id,
a.waybill_id,
a.bill_code,
a.sales_support,
a.money_user_id,
mu.company as money_company,
a.del_flag,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.create_site,
a.update_site,
a.remark
from emis_waybill_other a
left join emis_money_user mu on a.money_user_id = mu.id and mu.del_flag = '0'
</sql> </sql>
<select id="selectEmisWaybillOtherById" parameterType="Long" resultMap="EmisWaybillOtherResult"> <select id="selectEmisWaybillOtherById" parameterType="Long" resultMap="EmisWaybillOtherResult">
<include refid="selectEmisWaybillOtherVo"/> <include refid="selectEmisWaybillOtherVo"/>
where id = #{id} and del_flag = '0' where a.id = #{id} and a.del_flag = '0'
</select> </select>
<select id="selectEmisWaybillOtherByWaybillId" parameterType="Long" resultMap="EmisWaybillOtherResult"> <select id="selectEmisWaybillOtherByWaybillId" parameterType="Long" resultMap="EmisWaybillOtherResult">
<include refid="selectEmisWaybillOtherVo"/> <include refid="selectEmisWaybillOtherVo"/>
where waybill_id = #{waybillId} and del_flag = '0' where a.waybill_id = #{waybillId} and a.del_flag = '0'
limit 1 limit 1
</select> </select>
<select id="selectEmisWaybillOtherByBillCode" parameterType="String" resultMap="EmisWaybillOtherResult"> <select id="selectEmisWaybillOtherByBillCode" parameterType="String" resultMap="EmisWaybillOtherResult">
<include refid="selectEmisWaybillOtherVo"/> <include refid="selectEmisWaybillOtherVo"/>
where bill_code = #{billCode} and del_flag = '0' where a.bill_code = #{billCode} and a.del_flag = '0'
limit 1 limit 1
</select> </select>
@ -39,6 +56,7 @@
<if test="waybillId != null">waybill_id,</if> <if test="waybillId != null">waybill_id,</if>
<if test="billCode != null and billCode != ''">bill_code,</if> <if test="billCode != null and billCode != ''">bill_code,</if>
<if test="salesSupport != null and salesSupport != ''">sales_support,</if> <if test="salesSupport != null and salesSupport != ''">sales_support,</if>
<if test="moneyUserId != null">money_user_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if> <if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
@ -52,6 +70,7 @@
<if test="waybillId != null">#{waybillId},</if> <if test="waybillId != null">#{waybillId},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if> <if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="salesSupport != null and salesSupport != ''">#{salesSupport},</if> <if test="salesSupport != null and salesSupport != ''">#{salesSupport},</if>
<if test="moneyUserId != null">#{moneyUserId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if> <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
@ -69,6 +88,7 @@
<if test="waybillId != null">waybill_id = #{waybillId},</if> <if test="waybillId != null">waybill_id = #{waybillId},</if>
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if> <if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="salesSupport != null">sales_support = #{salesSupport},</if> <if test="salesSupport != null">sales_support = #{salesSupport},</if>
<if test="moneyUserId != null">money_user_id = #{moneyUserId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if> <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>