表格导出

This commit is contained in:
xiaofajia 2024-12-03 18:03:18 +08:00
parent de22fa9e2e
commit c13d4402aa
17 changed files with 885 additions and 9 deletions

View File

@ -45,4 +45,6 @@ public class DictBaseConstants {
public static final String DICT_CAR_CATEGORY = "car_category"; public static final String DICT_CAR_CATEGORY = "car_category";
/** 车辆性质 */ /** 车辆性质 */
public static final String DICT_CAR_NATURE = "car_nature"; public static final String DICT_CAR_NATURE = "car_nature";
/** 支付方式 */
public static final String REPAIR_PAY_TYPE = "repair_pay_type";
} }

View File

@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.order.controller.admin; package cn.iocoder.yudao.module.order.controller.admin;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.order.entity.RepairOrderInfo; import cn.iocoder.yudao.module.order.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.order.service.RepairOrderInfoService; import cn.iocoder.yudao.module.order.service.RepairOrderInfoService;
import cn.iocoder.yudao.module.order.vo.RepairOrderExportVO;
import cn.iocoder.yudao.module.order.vo.RepairOrderInfoPageReqVO; import cn.iocoder.yudao.module.order.vo.RepairOrderInfoPageReqVO;
import cn.iocoder.yudao.module.order.vo.RepairOrderInfoRespVO; import cn.iocoder.yudao.module.order.vo.RepairOrderInfoRespVO;
import cn.iocoder.yudao.module.order.vo.RepairOrderInfoSaveReqVO; import cn.iocoder.yudao.module.order.vo.RepairOrderInfoSaveReqVO;
@ -17,13 +20,18 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.SignatureException; import java.security.SignatureException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 维修模块 订单") @Tag(name = "管理后台 - 维修模块 订单")
@ -113,4 +121,48 @@ public class RepairOrderInfoController {
public CommonResult<?> toPay(@RequestParam("id")String id) throws IOException, NoSuchAlgorithmException, SignatureException, InvalidKeyException { public CommonResult<?> toPay(@RequestParam("id")String id) throws IOException, NoSuchAlgorithmException, SignatureException, InvalidKeyException {
return success(repairOrderInfoService.payTransactionsCode(id)); return success(repairOrderInfoService.payTransactionsCode(id));
} }
/**
* 导出数据
*
* @author 小李
* @date 17:03 2024/12/3
* @param pageReqVO 请求对象
**/
@GetMapping("/export")
@Operation(summary = "导出数据")
public void exportData(RepairOrderInfoPageReqVO pageReqVO, HttpServletResponse response)throws IOException{
int pageNo = 1, pageSize = 1000;
List<RepairOrderExportVO> list = new ArrayList<>();
Page<RepairOrderInfoRespVO> page = new Page<>(pageNo, pageSize);
do {
IPage<RepairOrderInfoRespVO> repairOrderInfoRespVOIPage = repairOrderInfoService.queryListPage(pageReqVO, page);
List<RepairOrderInfoRespVO> records = repairOrderInfoRespVOIPage.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
List<RepairOrderExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, RepairOrderExportVO.class)).collect(Collectors.toList());
list.addAll(convertedRecords);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(list)){
throw exception0(500, "没有数据可以导出");
}
list.forEach(item -> {
switch (item.getGoodsType()){
case "1":
item.setGoodsType("会员充值");
break;
case "2":
item.setGoodsType("维修服务");
break;
case "3":
item.setGoodsType("保养卡");
break;
}
item.setOrderStatus(item.getOrderStatus().equals("0") ? "待支付" : "已支付");
});
ExcelUtils.write(response, "订单数据.xls", "数据", RepairOrderExportVO.class, list);
}
} }

View File

@ -0,0 +1,63 @@
package cn.iocoder.yudao.module.order.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.common.DictBaseConstants.REPAIR_PAY_TYPE;
/**
* 用于维修订单导出VO
*
* @author 小李
* @date 17:05 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class RepairOrderExportVO {
@ExcelProperty("订单号")
private String orderNo;
@ExcelProperty("服务名称")
private String goodsTitle;
@ExcelProperty("消费类型")
private String goodsType;
@ExcelProperty("客户姓名")
private String cusName;
@ExcelProperty("客户手机号")
private String cusPhone;
@ExcelProperty("商品原价(元)")
private BigDecimal goodsPrice;
@ExcelProperty("实付金额(元)")
private BigDecimal payMoney;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ExcelProperty("下单时间")
private LocalDateTime orderTime;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ExcelProperty("支付时间")
private LocalDateTime payTime;
@ExcelProperty(value = "支付方式", converter = DictConvert.class)
@DictFormat(REPAIR_PAY_TYPE)
private String payType;
@ExcelProperty("订单状态")
private String orderStatus;
}

View File

@ -22,4 +22,16 @@ public interface RepairDictConstants {
/** 维修工人工种 */ /** 维修工人工种 */
String REPAIR_WORK_TYPE = "repair_work_type"; String REPAIR_WORK_TYPE = "repair_work_type";
/** 维修类别 */
String REPAIR_TYPE = "repair_type";
/** 配件申请单审核状态 */
String TICKET_WARES_STATUS = "ticket_wares_status";
/** 库存操作单据状态 */
String REPAIR_SO_STATUS = "repair_so_status";
/** 调拨状态 */
String REPAIR_ST_STATUS = "repair_st_status";
} }

View File

@ -1,17 +1,29 @@
package cn.iocoder.yudao.module.stockOperate.controller.admin; package cn.iocoder.yudao.module.stockOperate.controller.admin;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo; import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService; import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO; import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO; import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO;
import cn.iocoder.yudao.module.stockOperate.vo.RepairSoExportVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
@ -144,5 +156,28 @@ public class DlRepairSoController {
dlRepairSoService.inWare(repairSoRespVO); dlRepairSoService.inWare(repairSoRespVO);
return CommonResult.ok(); return CommonResult.ok();
} }
@GetMapping("/export")
@Operation(summary = "导出数据")
public void exportData(DlRepairSoReqVO repairSoReqVO, HttpServletResponse response)throws IOException {
int pageNo = 1, pageSize = 1000;
List<RepairSoExportVO> list = new ArrayList<>();
Page<DlRepairSo> page = new Page<>(pageNo, pageSize);
do {
IPage<DlRepairSo> repairSoPage = dlRepairSoService.getRepairSoPage(repairSoReqVO, page);
List<DlRepairSo> records = repairSoPage.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
List<RepairSoExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, RepairSoExportVO.class)).collect(Collectors.toList());
list.addAll(convertedRecords);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(list)){
throw exception0(500, "没有数据可以导出");
}
ExcelUtils.write(response, "单据数据.xls", "数据", RepairSoExportVO.class, list);
}
} }

View File

@ -1,22 +1,37 @@
package cn.iocoder.yudao.module.stockOperate.controller.admin; package cn.iocoder.yudao.module.stockOperate.controller.admin;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.conf.entity.BaseWarehouse;
import cn.iocoder.yudao.module.conf.service.BaseWarehouseService;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi; import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi;
import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoiService; import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoiService;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiReqVO; import cn.iocoder.yudao.module.stockOperate.vo.*;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiRespVO; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
@ -33,6 +48,10 @@ public class DlRepairSoiController{
@Resource @Resource
private DlRepairSoiService dlRepairSoiService; private DlRepairSoiService dlRepairSoiService;
@Resource
@Lazy
private BaseWarehouseService warehouseService;
/** /**
* 采购单领料单子表 分页 * 采购单领料单子表 分页
* *
@ -107,5 +126,61 @@ public class DlRepairSoiController{
Page<DlRepairSoiRespVO> page = new Page<>(pageNo, pageSize); Page<DlRepairSoiRespVO> page = new Page<>(pageNo, pageSize);
return success(dlRepairSoiService.getSoBySupplier(reqVO, page)); return success(dlRepairSoiService.getSoBySupplier(reqVO, page));
} }
/**
* 导出数据
*
* @author 小李
* @date 16:30 2024/12/3
**/
@GetMapping("/export")
@Operation(summary = "导出数据")
public void exportData(DlRepairSoiReqVO repairSoiReqVO, HttpServletResponse response)throws IOException {
int pageNo = 1, pageSize = 1000;
Page<DlRepairSoi> page = new Page<>(pageNo, pageSize);
List<DlRepairSoi> allList = new ArrayList<>();
do {
IPage<DlRepairSoi> repairSoiPage = dlRepairSoiService.getRepairSoiPage(repairSoiReqVO, page);
List<DlRepairSoi> records = repairSoiPage.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
allList.addAll(records);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(allList)){
throw exception0(500, "没有数据可以导出");
}
List<String> ids = allList.stream().map(DlRepairSoi::getId).collect(Collectors.toList());
List<DlRepairSoiQueryRespVO> repairSoiByIds = dlRepairSoiService.getRepairSoiByIds(ids);
List<BaseWarehouse> warehouses = warehouseService.list();
Map<String, String> warehousesMap = warehouses.stream().collect(Collectors.toMap(BaseWarehouse::getId, BaseWarehouse::getName));
List<RepairSoiExportVO> list = repairSoiByIds.stream().map(item -> {
DlRepairSo so = item.getSo();
RepairWares repairWares = item.getRepairWares();
RepairSoiExportVO repairSoiExportVO = new RepairSoiExportVO();
repairSoiExportVO.setSoNo(so.getSoNo());
repairSoiExportVO.setName(repairWares.getName());
repairSoiExportVO.setUserName(so.getUserName());
repairSoiExportVO.setCode(repairWares.getCode());
repairSoiExportVO.setBarCode(repairWares.getBarCode());
repairSoiExportVO.setModel(repairWares.getModel());
repairSoiExportVO.setGoodsCount(item.getGoodsCount());
repairSoiExportVO.setGoodsPrice(item.getGoodsPrice());
BigDecimal goodsPrice = ObjectUtil.isNotEmpty(item.getGoodsPrice()) ? item.getGoodsPrice() : BigDecimal.ZERO;
int goodsCount = ObjectUtil.isNotEmpty(item.getGoodsCount()) ? item.getGoodsCount() : 0;
repairSoiExportVO.setTotal(goodsPrice.multiply(BigDecimal.valueOf(goodsCount)));
repairSoiExportVO.setSupplierName(so.getSupplierName());
if (ObjectUtil.isNotEmpty(item.getWareId())) {
repairSoiExportVO.setWarehouseName(warehousesMap.get(item.getWareId()));
}
repairSoiExportVO.setCropId(so.getCorpId());
repairSoiExportVO.setCreateTime(so.getCreateTime());
repairSoiExportVO.setRemark(item.getRemark());
return repairSoiExportVO;
}).collect(Collectors.toList());
ExcelUtils.write(response, "作废单据数据.xls", "数据", RepairSoiExportVO.class, list);
}
} }

View File

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.stockOperate.vo;
import cn.iocoder.yudao.common.RepairDictConstants;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 用于采购单导出VO
*
* @author 小李
* @date 16:03 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class RepairSoExportVO {
/**
* 单据编号;自动生成
*/
@ExcelProperty("单号")
private String soNo;
@ExcelProperty("供应商")
private String supplierName;
@ExcelProperty("操作人")
private String userName;
@ExcelProperty("数量")
private Integer itemCount;
@ExcelProperty("金额")
private BigDecimal totalPrice;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat(RepairDictConstants.REPAIR_SO_STATUS)
private String soStatus;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("门店")
private String corpName;
}

View File

@ -0,0 +1,65 @@
package cn.iocoder.yudao.module.stockOperate.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 用于导出库存操作子表的VO
*
* @author 小李
* @date 16:32 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class RepairSoiExportVO {
@ExcelProperty("单号")
private String soNo;
@ExcelProperty("商品名称")
private String name;
@ExcelProperty("操作人")
private String userName;
@ExcelProperty("商品编码")
private String code;
@ExcelProperty("条形码")
private String barCode;
@ExcelProperty("规格")
private String model;
@ExcelProperty("数量")
private Integer goodsCount;
@ExcelProperty("价格")
private BigDecimal goodsPrice;
@ExcelProperty("合计")
private BigDecimal total;
@ExcelProperty("供应商")
private String supplierName;
@ExcelProperty("仓库")
private String warehouseName;
@ExcelProperty("门店")
private String cropId;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ExcelProperty("时间")
private LocalDateTime createTime;
@ExcelProperty("备注")
private String remark;
}

View File

@ -1,17 +1,34 @@
package cn.iocoder.yudao.module.stockTransfer.controller.admin; package cn.iocoder.yudao.module.stockTransfer.controller.admin;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.service.CompanyService;
import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt;
import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStService; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStService;
import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStReqVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStReqVO;
import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO;
import cn.iocoder.yudao.module.stockTransfer.vo.RepairStExportVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
@ -28,6 +45,10 @@ public class DlRepairStController{
@Resource @Resource
private DlRepairStService dlRepairStService; private DlRepairStService dlRepairStService;
@Resource
@Lazy
private CompanyService companyService;
/** /**
* 调拨单 新增 * 调拨单 新增
* *
@ -86,5 +107,45 @@ public class DlRepairStController{
public CommonResult<?> getSt(@RequestParam("id") String id){ public CommonResult<?> getSt(@RequestParam("id") String id){
return success(dlRepairStService.getSt(id)); return success(dlRepairStService.getSt(id));
} }
/**
* 导出数据
*
* @author 小李
* @date 17:26 2024/12/3
* @param repairStReqVO 请求对象
**/
@GetMapping("/export")
@Operation(summary = "导出数据")
public void exportData(DlRepairStReqVO repairStReqVO, HttpServletResponse response)throws IOException {
int pageNo = 1, pageSize = 1000;
List<RepairStExportVO> list = new ArrayList<>();
Page<DlRepairSt> page = new Page<>(pageNo, pageSize);
do {
IPage<DlRepairSt> stPage = dlRepairStService.getStPage(repairStReqVO, page);
List<DlRepairSt> records = stPage.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
List<RepairStExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, RepairStExportVO.class)).collect(Collectors.toList());
list.addAll(convertedRecords);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(list)){
throw exception0(500, "没有数据可以导出");
}
List<Company> companies = companyService.list();
Map<String, String> companyMap = companies.stream().collect(Collectors.toMap(Company::getId, Company::getCorpName));
list.forEach(item -> {
if (ObjectUtil.isNotEmpty(item.getInCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(item.getInCorpId()))){
item.setInCorpId(companyMap.get(item.getInCorpId()));
}
if (ObjectUtil.isNotEmpty(item.getOutCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(item.getOutCorpId()))){
item.setOutCorpId(companyMap.get(item.getOutCorpId()));
}
});
ExcelUtils.write(response, "单据数据.xls", "数据", RepairStExportVO.class, list);
}
} }

View File

@ -1,21 +1,39 @@
package cn.iocoder.yudao.module.stockTransfer.controller.admin; package cn.iocoder.yudao.module.stockTransfer.controller.admin;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.service.CompanyService;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt;
import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti;
import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStiService; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStiService;
import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiQueryVO;
import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiReqVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiReqVO;
import cn.iocoder.yudao.module.stockTransfer.vo.RepairSoiExportVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
@ -32,6 +50,10 @@ public class DlRepairStiController{
@Resource @Resource
private DlRepairStiService dlRepairStiService; private DlRepairStiService dlRepairStiService;
@Resource
@Lazy
private CompanyService companyService;
/** /**
* 调拨单子表 分页 * 调拨单子表 分页
* *
@ -62,5 +84,64 @@ public class DlRepairStiController{
public CommonResult<?> getStIsWares(@RequestParam("ids") List<String> ids){ public CommonResult<?> getStIsWares(@RequestParam("ids") List<String> ids){
return success(dlRepairStiService.getStIsWares(ids)); return success(dlRepairStiService.getStIsWares(ids));
} }
/**
* 导出数据
*
* @author 小李
* @date 17:43 2024/12/3
* @param repairStiReqVO 请求对象
**/
@GetMapping("/export")
@Operation(summary = "导出数据")
public void exportData(DlRepairStiReqVO repairStiReqVO, HttpServletResponse response)throws IOException {
int pageNo = 1, pageSize = 1000;
Page<DlRepairSti> page = new Page<>(pageNo, pageSize);
List<DlRepairSti> allList = new ArrayList<>();
do {
IPage<DlRepairSti> stiPage = dlRepairStiService.getStiPage(repairStiReqVO, page);
List<DlRepairSti> records = stiPage.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
allList.addAll(records);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(allList)){
throw exception0(500, "没有数据可以导出");
}
List<Company> companies = companyService.list();
Map<String, String> companyMap = companies.stream().collect(Collectors.toMap(Company::getId, Company::getCorpName));
List<String> ids = allList.stream().map(DlRepairSti::getId).collect(Collectors.toList());
List<DlRepairStiQueryVO> stIsWares = dlRepairStiService.getStIsWares(ids);
List<RepairSoiExportVO> list = stIsWares.stream().map(item -> {
RepairSoiExportVO repairSoiExportVO = new RepairSoiExportVO();
DlRepairSt st = item.getSt();
RepairWares wares = item.getWares();
repairSoiExportVO.setStNo(st.getStNo());
repairSoiExportVO.setName(wares.getName());
repairSoiExportVO.setModel(wares.getModel());
repairSoiExportVO.setCode(wares.getCode());
repairSoiExportVO.setBarCode(wares.getBarCode());
repairSoiExportVO.setGoodsCount(item.getGoodsCount());
repairSoiExportVO.setPrice(wares.getPrice());
int goodsCount = ObjectUtil.isNotEmpty(item.getGoodsCount()) ? item.getGoodsCount() : 0;
BigDecimal price = ObjectUtil.isNotEmpty(wares.getPrice()) ? wares.getPrice() : BigDecimal.ZERO;
repairSoiExportVO.setTotalPrice(price.multiply(BigDecimal.valueOf(goodsCount)));
repairSoiExportVO.setGoodsPrice(item.getGoodsPrice());
repairSoiExportVO.setUserName(st.getUserName());
if (ObjectUtil.isNotEmpty(st.getInCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(st.getInCorpId()))) {
repairSoiExportVO.setInCorpId(companyMap.get(st.getInCorpId()));
}
if (ObjectUtil.isNotEmpty(st.getOutCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(st.getOutCorpId()))) {
repairSoiExportVO.setOutCorpId(companyMap.get(st.getOutCorpId()));
}
repairSoiExportVO.setStTime(st.getStTime());
repairSoiExportVO.setRemark(item.getRemark());
return repairSoiExportVO;
}).collect(Collectors.toList());
ExcelUtils.write(response, "调拨详细数据.xls", "数据", RepairSoiExportVO.class, list);
}
} }

View File

@ -0,0 +1,66 @@
package cn.iocoder.yudao.module.stockTransfer.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 用于调拨单子表导出VO
*
* @author 小李
* @date 17:43 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class RepairSoiExportVO {
@ExcelProperty("单号")
private String stNo;
@ExcelProperty("商品名称")
private String name;
@ExcelProperty("规格")
private String model;
@ExcelProperty("商品编码")
private String code;
@ExcelProperty("条形码")
private String barCode;
@ExcelProperty("数量")
private Integer goodsCount;
@ExcelProperty("成本")
private BigDecimal price;
@ExcelProperty("金额")
private BigDecimal goodsPrice;
@ExcelProperty("合计金额")
private BigDecimal totalPrice;
@ExcelProperty("负责人")
private String userName;
@ExcelProperty("调出门店")
private String outCorpId;
@ExcelProperty("调入门店")
private String inCorpId;
@ExcelProperty("调拨时间")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date stTime;
@ExcelProperty("备注")
private String remark;
}

View File

@ -0,0 +1,54 @@
package cn.iocoder.yudao.module.stockTransfer.vo;
import cn.iocoder.yudao.common.RepairDictConstants;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 用于调拨相关的导出VO
*
* @author 小李
* @date 17:27 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class RepairStExportVO {
@ExcelProperty("调出门店")
private String outCorpId;
@ExcelProperty("调入门店")
private String inCorpId;
@ExcelProperty("单号")
private String stNo;
@ExcelProperty("调拨人")
private String userName;
@ExcelProperty("总数量")
private Integer itemCount;
@ExcelProperty("总金额")
private BigDecimal totalPrice;
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat(RepairDictConstants.REPAIR_ST_STATUS)
private String stStatus;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ExcelProperty("调拨日期")
private Date stTime;
@ExcelProperty("备注")
private String remark;
}

View File

@ -1,15 +1,16 @@
package cn.iocoder.yudao.module.tickets.controller.admin; package cn.iocoder.yudao.module.tickets.controller.admin;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.common.RepairCons; import cn.iocoder.yudao.common.RepairCons;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets; import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import cn.iocoder.yudao.module.tickets.vo.CustomerAndCarVO; import cn.iocoder.yudao.module.tickets.vo.*;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsReqVO; import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import cn.iocoder.yudao.module.tickets.vo.NoticeCusVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -17,10 +18,11 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Date; import java.io.IOException;
import java.util.HashMap; import java.util.*;
import java.util.Map; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
@ -438,5 +440,81 @@ public class DlRepairTicketsController {
public CommonResult<?> getCusAndCarById(@RequestParam("id") String id) { public CommonResult<?> getCusAndCarById(@RequestParam("id") String id) {
return success(dlRepairTicketsService.getCusAndCarById(id)); return success(dlRepairTicketsService.getCusAndCarById(id));
} }
/**
* 导出数据
*
* @author 小李
* @date 14:51 2024/12/3
* @param repairTicketsReqVO 请求对象
**/
@GetMapping("/export")
@Operation(summary = "导出数据")
public void exportData(DlRepairTicketsReqVO repairTicketsReqVO, HttpServletResponse response)throws IOException {
int pageNo = 1, pageSize = 1000;
Page<DlRepairTickets> page = new Page<>(pageNo, pageSize);
if (StringUtils.isEmpty(repairTicketsReqVO.getSelectType())) {
//查询类型为空默认查待处理的
repairTicketsReqVO.setSelectType(RepairCons.TICKETS_WAITING);
}
List<TicketsExportVO> list = new ArrayList<>();
do {
IPage<DlRepairTickets> pageType = dlRepairTicketsService.getPageType(repairTicketsReqVO, page);
List<DlRepairTickets> records = pageType.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
List<TicketsExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, TicketsExportVO.class)).collect(Collectors.toList());
list.addAll(convertedRecords);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(list)){
throw exception0(500, "没有数据可以导出");
}
ExcelUtils.write(response, "工单数据.xls", "数据", TicketsExportVO.class, list);
}
/**
* 导出数据 根据工单状态
*
* @author 小李
* @date 15:19 2024/12/3
* @param repairTicketsReqVO 请求对象
**/
@GetMapping("/exportByStatus")
@Operation(summary = "导出数据 根据工单状态")
public void exportByStatus(DlRepairTicketsReqVO repairTicketsReqVO, HttpServletResponse response)throws IOException{
int pageNo = 1, pageSize = 1000;
List<TicketExportByStatusVO> list = new ArrayList<>();
Page<DlRepairTickets> page = new Page<>(pageNo, pageSize);
do {
IPage<DlRepairTickets> ticketsPage = dlRepairTicketsService.getTicketsPage(repairTicketsReqVO, page);
List<DlRepairTickets> records = ticketsPage.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
List<TicketExportByStatusVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, TicketExportByStatusVO.class)).collect(Collectors.toList());
list.addAll(convertedRecords);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(list)){
throw exception0(500, "没有数据可以导出");
}
String name = "";
switch (repairTicketsReqVO.getTicketsStatus()){
case "01":
name = "待结算工单数据.xls";
break;
case "02":
name = "已结算工单数据.xls";
break;
case "03":
name = "已作废工单数据.xls";
break;
}
ExcelUtils.write(response, name, "数据", TicketExportByStatusVO.class, list);
}
} }

View File

@ -1,18 +1,28 @@
package cn.iocoder.yudao.module.tickets.controller.admin; package cn.iocoder.yudao.module.tickets.controller.admin;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.tickets.entity.DlTicketWares; import cn.iocoder.yudao.module.tickets.entity.DlTicketWares;
import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService; import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService;
import cn.iocoder.yudao.module.tickets.vo.DlTicketWaresReqVO; import cn.iocoder.yudao.module.tickets.vo.DlTicketWaresReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlTicketWaresRespVO; import cn.iocoder.yudao.module.tickets.vo.DlTicketWaresRespVO;
import cn.iocoder.yudao.module.tickets.vo.TicketWaresExportVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
@ -210,5 +220,35 @@ public class DlTicketWaresController {
public CommonResult<?> getByIds(@RequestParam("ids") List<String> ids){ public CommonResult<?> getByIds(@RequestParam("ids") List<String> ids){
return success(dlTicketWaresService.getByIds(ids)); return success(dlTicketWaresService.getByIds(ids));
} }
/**
* 导出数据
*
* @author 小李
* @date 15:02 2024/12/3
* @param reqVO 请求对象
**/
@GetMapping("/export")
@Operation(summary = "导出数据")
public void exportData(DlTicketWaresReqVO reqVO, HttpServletResponse response)throws IOException {
int pageNo = 1, pageSize = 1000;
List<TicketWaresExportVO> list = new ArrayList<>();
Page<DlTicketWares> page = new Page<>(pageNo, pageSize);
do {
IPage<DlTicketWares> waresServicePage = dlTicketWaresService.getPage(reqVO, page);
List<DlTicketWares> records = waresServicePage.getRecords();
if (CollUtil.isEmpty(records)){
break;
}
List<TicketWaresExportVO> convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, TicketWaresExportVO.class)).collect(Collectors.toList());
list.addAll(convertedRecords);
pageNo++;
page.setCurrent(pageNo);
}while (true);
if (CollUtil.isEmpty(list)){
throw exception0(500, "没有数据可以导出");
}
ExcelUtils.write(response, "配件申请单数据.xls", "数据", TicketWaresExportVO.class, list);
}
} }

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.tickets.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 用于导出不对状态的工单
*
* @author 小李
* @date 15:21 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class TicketExportByStatusVO extends TicketsExportVO{
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@ExcelProperty("合计金额")
private BigDecimal totalPrice;
@ExcelProperty("参考成本")
private BigDecimal cost;
@ExcelProperty("参考毛利")
private BigDecimal profit;
@ExcelProperty("服务顾问")
private String adviserName;
@ExcelProperty("备注")
private String remark;
}

View File

@ -0,0 +1,48 @@
package cn.iocoder.yudao.module.tickets.vo;
import cn.iocoder.yudao.common.RepairDictConstants;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 用于配件申请单数据导出VO
*
* @author 小李
* @date 15:03 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class TicketWaresExportVO {
@ExcelProperty("单据号")
private String no;
@ExcelProperty("客户名称")
private String userName;
@ExcelProperty("客户电话")
private String userMobile;
@ExcelProperty("车牌号")
private String licenseNumber;
@ExcelProperty("申请人")
private String repairName;
@ExcelProperty(value = "岗位", converter = DictConvert.class)
@DictFormat(RepairDictConstants.REPAIR_WORK_TYPE)
private String repairWork;
@ExcelProperty("服务顾问")
private String adviserName;
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat(RepairDictConstants.TICKET_WARES_STATUS)
private String status;
@ExcelProperty("备注")
private String remark;
}

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.tickets.vo;
import cn.iocoder.yudao.common.RepairDictConstants;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 用于工单数据导出
*
* @author 小李
* @date 14:41 2024/12/3
**/
@Data
@ExcelIgnoreUnannotated
public class TicketsExportVO {
@ExcelProperty("订单编号")
private String ticketNo;
@ExcelProperty(value = "维修类别", converter = DictConvert.class)
@DictFormat(RepairDictConstants.REPAIR_TYPE)
private String repairType;
@ExcelProperty("客户名称")
private String userName;
@ExcelProperty("车牌号")
private String carNo;
@ExcelProperty("车系")
private String carBrandName;
@ExcelProperty("手机号")
private String userMobile;
@ExcelProperty("经办人姓名")
private String handleName;
@ExcelProperty("经办人电话")
private String handleMobile;
}