交班记录代码提交

This commit is contained in:
Tankaikai 2025-02-28 15:36:41 +08:00
parent 7eae3c6f68
commit 7cdce51c58
8 changed files with 147 additions and 4 deletions

View File

@ -1,12 +1,18 @@
package com.czg.controller.admin;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 交班
@ -20,6 +26,45 @@ import org.springframework.web.bind.annotation.*;
public class HandoverRecordController {
private final HandoverRecordService handoverRecordService;
/**
* 交班记录-分页
*
* @param beginDate 开始时间 格式yyyy-MM-dd
* @param endDate 结束时间 格式yyyy-MM-dd
*/
@GetMapping("page")
@OperationLog("交班记录-分页")
//@SaAdminCheckPermission("handoverRecord:page")
public CzgResult<Page<HandoverRecordDTO>> page(@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate) {
Page<HandoverRecordDTO> page = handoverRecordService.getHandoverRecordPage(beginDate, endDate);
return CzgResult.success(page);
}
/**
* 交班记录-查看
*
* @param id 交班记录ID
*/
@GetMapping("{id}")
@OperationLog("交班记录-查看")
//@SaAdminCheckPermission("handoverRecord:info")
public CzgResult<List<HandoverProductListVo>> info(@PathVariable Long id) {
List<HandoverProductListVo> data = handoverRecordService.getHandoverProductListById(id);
return CzgResult.success(data);
}
/**
* 交班记录-导出
*
* @param id 交班记录ID
*/
@ResponseExcel(name = "交班售出商品明细")
@GetMapping("/export/{id}")
@OperationLog("交班记录-导出")
//@SaAdminCheckPermission("handoverRecord:export")
public List<HandoverProductListVo> export(@PathVariable Long id) {
return handoverRecordService.getHandoverProductListById(id);
}
/**
* 收银机-交班数据统计
@ -34,6 +79,7 @@ public class HandoverRecordController {
/**
* 收银机-交班/关班
*
* @param isPrint 是否打印交班小票
*/
@PostMapping("handover")

View File

@ -52,6 +52,10 @@
<artifactId>cash-common-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -30,6 +30,10 @@
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
</dependency>
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +1,6 @@
package com.czg.account.dto;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import java.io.Serial;
@ -97,4 +98,15 @@ public class HandoverRecordDTO implements Serializable {
*/
private Integer orderCount;
/**
* 查询开始日期 yyyy-MM-dd
*/
@JSONField(serialize = false)
private String beginDate;
/**
* 查询结束日期 yyyy-MM-dd
*/
@JSONField(serialize = false)
private String endDate;
}

View File

@ -1,9 +1,14 @@
package com.czg.account.service;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import java.util.List;
/**
* 交班记录表
*
@ -11,6 +16,24 @@ import com.mybatisflex.core.service.IService;
* @since 1.0 2025-02-27
*/
public interface HandoverRecordService extends IService<HandoverRecord> {
/**
* 会员积分分页
*
* @param beginDate 开始日期
* @param endDate 结束日期
* @return 分页结果
*/
Page<HandoverRecordDTO> getHandoverRecordPage(String beginDate, String endDate);
/**
* 根据交班记录ID获取商品列表
*
* @param id 交班记录ID
* @return 商品列表
*/
List<HandoverProductListVo> getHandoverProductListById(Long id);
/**
* 统计交班数据
*

View File

@ -1,5 +1,10 @@
package com.czg.account.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.alibaba.fastjson2.annotation.JSONField;
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
import lombok.Data;
import java.io.Serial;
@ -13,32 +18,46 @@ import java.math.BigDecimal;
* @since 2025-02-27 15:34
*/
@Data
@ColumnWidth(30)
public class HandoverProductListVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
@JSONField(serialize = false)
private Long lineNum;
/**
* 商品id
*/
@ExcelIgnore
private Long productId;
/**
* sku id
*/
@ExcelIgnore
private Long skuId;
/**
* 商品名称
*/
@ExcelProperty("商品名称")
private String productName;
/**
* 规格名称
*/
@ExcelProperty("规格")
private String skuName;
/**
* 商品数量
*/
@ExcelProperty("数量")
private BigDecimal num;
/**
* 小计商品金额
*/
@ExcelProperty("金额")
private BigDecimal amount;
}

View File

@ -233,7 +233,13 @@
<artifactId>spring-data-redis</artifactId>
<version>${spring-data-redis.version}</version>
</dependency>
<!-- excel 导入导出工具类https://github.com/pig-mesh/excel-spring-boot-starter -->
<!-- 参考文档https://www.yuque.com/pig4cloud/excel -->
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -3,6 +3,7 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import com.czg.account.dto.HandoverRecordDTO;
@ -15,6 +16,7 @@ import com.czg.order.service.OrderInfoRpcService;
import com.czg.sa.StpKit;
import com.czg.service.account.mapper.HandoverRecordMapper;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboReference;
@ -39,16 +41,43 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
private QueryWrapper buildQueryWrapper(HandoverRecordDTO param) {
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
/*if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(HandoverRecord::getName, param.getName());
}*/
if (StrUtil.isNotEmpty(param.getBeginDate())) {
queryWrapper.ge(HandoverRecord::getHandoverTime, param.getBeginDate() + " 00:00:00");
}
if (StrUtil.isNotEmpty(param.getEndDate())) {
queryWrapper.le(HandoverRecord::getHandoverTime, param.getEndDate() + " 23:59:59");
}
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(HandoverRecord::getShopId, shopId);
queryWrapper.isNotNull(HandoverRecord::getHandoverTime);
queryWrapper.orderBy(HandoverRecord::getId, false);
return queryWrapper;
}
@Override
public Page<HandoverRecordDTO> getHandoverRecordPage(String beginDate, String endDate) {
HandoverRecordDTO param = new HandoverRecordDTO();
param.setBeginDate(beginDate);
param.setEndDate(endDate);
QueryWrapper queryWrapper = buildQueryWrapper(param);
return super.pageAs(PageUtil.buildPage(), queryWrapper, HandoverRecordDTO.class);
}
@Override
public List<HandoverProductListVo> getHandoverProductListById(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
HandoverRecord data = super.getOne(query().eq(HandoverRecord::getId, id).eq(HandoverRecord::getShopId, shopId));
if (data == null) {
return List.of();
}
String productData = data.getProductData();
if (StrUtil.isBlank(productData)) {
return List.of();
}
return JSON.parseArray(productData, HandoverProductListVo.class);
}
@Override
public HandoverTotalVo totalHandoverData() {
Long shopId = StpKit.USER.getShopId(0L);