diff --git a/crm-admin/src/main/java/com/yb/lb/webapp/excel/stock/StockExcel.java b/crm-admin/src/main/java/com/yb/lb/webapp/excel/stock/StockExcel.java index 3264ae9..ff174dc 100644 --- a/crm-admin/src/main/java/com/yb/lb/webapp/excel/stock/StockExcel.java +++ b/crm-admin/src/main/java/com/yb/lb/webapp/excel/stock/StockExcel.java @@ -5,8 +5,11 @@ import com.yb.lb.common.exception.CustomException; import com.yb.lb.common.utils.ErrorUtils; import com.yb.lb.webapp.excel.utils.EasyPoiUtils; import com.yb.lb.webapp.redis.service.RedisService; +import com.yb.lb.webapp.stock.entity.ClientStockReport; import com.yb.lb.webapp.stock.entity.CrmInventoryDetail; +import com.yb.lb.webapp.stock.service.ClientStockReportService; import com.yb.lb.webapp.stock.service.InventoryInfoService; +import com.yb.lb.webapp.utils.RoleDateUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -35,6 +39,10 @@ public class StockExcel { InventoryInfoService inventoryInfoService; @Autowired RedisService redisService; + @Autowired + RoleDateUtils roleDateUtils; + @Autowired + ClientStockReportService clientStockReportService; /** * @description 库存查询导出 @@ -75,8 +83,38 @@ public class StockExcel { /** * 导出客户库存盘点明细 + * * @author mzr * @date 2024/10/31 */ + @ApiOperation(value = "导出客户库存盘点明细") + @GetMapping(value = "/exportClientStockReport") + public void exportClientStockReport( + @ApiParam(required = true, value = "开始日期") @RequestParam(required = true) String startDate, + @ApiParam(required = true, value = "结束日期") @RequestParam(required = true) String endDate, + @ApiParam(required = false, value = "客户id") @RequestParam(required = false) String clientId, + @ApiParam(required = false, value = "客户编码U8") @RequestParam(required = false) String uecode, + @ApiParam(required = false, value = "客户名称") @RequestParam(required = false) String clientName, + @ApiParam(required = false, value = "业务员名称") @RequestParam(required = false) String staffName, + @ApiParam(required = false, value = "部门id") @RequestParam(required = false) String areaId, + HttpServletRequest request, HttpServletResponse response) throws Exception { + Map params = new HashMap<>(); + String token = request.getHeader("token"); + if (!redisService.isKey(token)) { + throw new CustomException("用户未登录", ErrorUtils.IS_NOT_LOGIN_ERROR); + } + params = roleDateUtils.roleUtiles(token, areaId, "", ""); + if ("0".equals(params.get("code"))) { + throw new CustomException("无权查看", ErrorUtils.USERNAME_POWER_ERROR); + } + params.put("startDate", startDate); + params.put("endDate", endDate); + params.put("clientId", clientId); + params.put("uecode", uecode); + params.put("clientName", clientName); + params.put("staffName", staffName); + List list = clientStockReportService.findList(params, ".getClientStockReportSql"); + EasyPoiUtils.exportExcel(list, ClientStockReport.class, "客户库存盘点明细导出", response); + } } diff --git a/crm-webapp/src/main/java/com/yb/lb/webapp/stock/entity/ClientStockReport.java b/crm-webapp/src/main/java/com/yb/lb/webapp/stock/entity/ClientStockReport.java index 95ffeb5..00612b5 100644 --- a/crm-webapp/src/main/java/com/yb/lb/webapp/stock/entity/ClientStockReport.java +++ b/crm-webapp/src/main/java/com/yb/lb/webapp/stock/entity/ClientStockReport.java @@ -1,5 +1,6 @@ package com.yb.lb.webapp.stock.entity; +import cn.afterturn.easypoi.excel.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -20,33 +21,41 @@ public class ClientStockReport implements java.io.Serializable { /** 客户编码-u8 */ @ApiModelProperty(value = "客户编码-u8") + @Excel(name = "客户编码", width = 15, orderNum = "2") private String uecode; /** 客户名称 */ @ApiModelProperty(value = "客户名称") + @Excel(name = "客户名称", width = 30, orderNum = "3") private String clientName; /** 业务员名称 */ @ApiModelProperty(value = "业务员名称") + @Excel(name = "业务员", width = 15, orderNum = "1") private String staffName; /** 部门名称 */ @ApiModelProperty(value = "部门名称") + @Excel(name = "区域", width = 15, orderNum = "0") private String areaName; /** 最新盘点日期 */ @ApiModelProperty(value = "最新盘点日期") + @Excel(name = "最新盘点日期", width = 15, orderNum = "6") private String billDate; /** 最新盘点数量 */ @ApiModelProperty(value = "最新盘点数量") + @Excel(name = "最新盘点数量", width = 15, orderNum = "5") private String countNum; /** 最新盘点种类数 */ @ApiModelProperty(value = "最新盘点种类数") + @Excel(name = "最新盘点种类数", width = 15, orderNum = "4") private String goodsNum; - /** 主键id */ + /** 盘点次数 */ @ApiModelProperty(value = "盘点次数") + @Excel(name = "盘点次数", width = 15, orderNum = "7") private String billNum; } \ No newline at end of file