Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
SongZhang 2024-10-11 16:42:58 +08:00
commit 6f50e1e134
11 changed files with 65 additions and 72 deletions

View File

@ -4,7 +4,6 @@ import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.ViewConInfoFlow; import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
import cn.ysk.cashier.cons.service.ViewConInfoFlowService; import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria; import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -35,8 +34,8 @@ public class ViewConInfoFlowController {
@PostMapping("get") @PostMapping("get")
@ApiOperation("查询获取耗材流水信息") @ApiOperation("查询获取耗材流水信息")
public ResponseEntity<Object> queryViewConInfoFlow(@RequestBody ViewConInfoFlowQueryCriteria criteria, Pageable pageable){ public ResponseEntity<Object> queryViewConInfoFlow(@RequestBody ViewConInfoFlowQueryCriteria criteria){
return new ResponseEntity<>(viewConInfoFlowService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(viewConInfoFlowService.queryAllPage(criteria),HttpStatus.OK);
} }
@PostMapping @PostMapping

View File

@ -3,7 +3,6 @@ package cn.ysk.cashier.cons.service;
import cn.ysk.cashier.cons.domain.ViewConInfoFlow; import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto; import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria; import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
@ -18,10 +17,9 @@ public interface ViewConInfoFlowService {
/** /**
* 查询数据分页 * 查询数据分页
* @param criteria 条件 * @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object> * @return Map<String,Object>
*/ */
Map<String,Object> queryAll(ViewConInfoFlowQueryCriteria criteria, Pageable pageable); Map<String,Object> queryAllPage(ViewConInfoFlowQueryCriteria criteria);
/** /**
* 查询所有数据不分页 * 查询所有数据不分页

View File

@ -32,4 +32,8 @@ public class ViewConInfoFlowQueryCriteria {
@Query(type = Query.Type.BETWEEN) @Query(type = Query.Type.BETWEEN)
private List<Date> createTime; private List<Date> createTime;
private Integer page;
private Integer size;
private String sort;
} }

View File

@ -1,48 +1,36 @@
package cn.ysk.cashier.cons.service.impl; package cn.ysk.cashier.cons.service.impl;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.cons.domain.TbConsInfo; import cn.ysk.cashier.cons.domain.TbConsInfo;
import cn.ysk.cashier.cons.domain.TbConsInfoFlow; import cn.ysk.cashier.cons.domain.TbConsInfoFlow;
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
import cn.ysk.cashier.dto.product.TbProductStockCountQueryCriteria;
import cn.ysk.cashier.dto.product.TbProductStockDetailQueryCriteria;
import cn.ysk.cashier.dto.product.TbProductStockListDto;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.pojo.shop.TbShopUnit;
import cn.ysk.cashier.repository.product.ProductStockCountRepository;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.TbProductStockCountVo;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository; import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository;
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
import cn.ysk.cashier.cons.service.TbConsInfoFlowService; import cn.ysk.cashier.cons.service.TbConsInfoFlowService;
import cn.ysk.cashier.cons.service.dto.TbConsInfoFlowDto; import cn.ysk.cashier.cons.service.dto.TbConsInfoFlowDto;
import cn.ysk.cashier.cons.service.dto.TbConsInfoFlowQueryCriteria; import cn.ysk.cashier.cons.service.dto.TbConsInfoFlowQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.TbConsInfoFlowMapper; import cn.ysk.cashier.cons.service.mapstruct.TbConsInfoFlowMapper;
import cn.ysk.cashier.dto.product.TbProductStockCountQueryCriteria;
import cn.ysk.cashier.dto.product.TbProductStockListDto;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.repository.product.ProductStockCountRepository;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.TbProductStockCountVo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page; import javax.servlet.http.HttpServletResponse;
import org.springframework.data.domain.Pageable; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2024-06-22
**/
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService { public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
@ -85,6 +73,7 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
//报损lossNumber; frmLoss //报损lossNumber; frmLoss
//入库stockInNumber; stockIn //入库stockInNumber; stockIn
//出库stockOutNumber; stockout //出库stockOutNumber; stockout
@Override
public Map<String,Object> queryPage(TbConsInfoFlowQueryCriteria criteria){ public Map<String,Object> queryPage(TbConsInfoFlowQueryCriteria criteria){
if(StringUtils.isNotBlank(criteria.getColumn())){ if(StringUtils.isNotBlank(criteria.getColumn())){
switch (criteria.getColumn()){ switch (criteria.getColumn()){
@ -95,25 +84,25 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
criteria.setBizCode(Arrays.asList("checkStockIn", "stockOtherIn")); criteria.setBizCode(Arrays.asList("checkStockIn", "stockOtherIn"));
break; break;
case "refundNumber": case "refundNumber":
criteria.setBizCode(Arrays.asList("cancelCart")); criteria.setBizCode(Collections.singletonList("cancelCart"));
break; break;
case "subCountNumber": case "subCountNumber":
criteria.setBizCode(Arrays.asList("createCart","stockout","checkStockOut")); criteria.setBizCode(Arrays.asList("createCart","stockout","checkStockOut"));
break; break;
case "subNumber": case "subNumber":
criteria.setBizCode(Arrays.asList("checkStockOut")); criteria.setBizCode(Collections.singletonList("checkStockOut"));
break; break;
case "saleNumber": case "saleNumber":
criteria.setBizCode(Arrays.asList("createCart")); criteria.setBizCode(Collections.singletonList("createCart"));
break; break;
case "lossNumber": case "lossNumber":
criteria.setBizCode(Arrays.asList("frmLoss")); criteria.setBizCode(Collections.singletonList("frmLoss"));
break; break;
case "stockInNumber": case "stockInNumber":
criteria.setBizCode(Arrays.asList("stockIn")); criteria.setBizCode(Collections.singletonList("stockIn"));
break; break;
case "stockOutNumber": case "stockOutNumber":
criteria.setBizCode(Arrays.asList("stockout")); criteria.setBizCode(Collections.singletonList("stockout"));
break; break;
} }
} }
@ -151,9 +140,7 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
criteria.getCategoryId(), criteria.getCategoryId(),
DateUtil.getStrTime(criteria.getStartTime()), DateUtil.getStrTime(criteria.getEndTime()), pageable); DateUtil.getStrTime(criteria.getStartTime()), DateUtil.getStrTime(criteria.getEndTime()), pageable);
if (!stockCountDtos.isEmpty()) { if (!stockCountDtos.isEmpty()) {
stockCountDtos.getContent().parallelStream().forEach(s->{ stockCountDtos.getContent().parallelStream().forEach(s-> s.setCountNumber(s.getStockNumber().add(s.getSubCountNumber())));
s.setCountNumber(s.getStockNumber().add(s.getSubCountNumber()));
});
} }
return PageUtil.toPage(stockCountDtos); return PageUtil.toPage(stockCountDtos);
} }

View File

@ -34,12 +34,6 @@ import java.io.IOException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2024-06-22
**/
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@ -75,7 +69,7 @@ public class TbProskuConServiceImpl implements TbProskuConService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public TbProskuConDto create(List<ProskuInfo> resources) throws BadRequestException,Exception { public TbProskuConDto create(List<ProskuInfo> resources) throws Exception {
log.info("List<ProskuInfo> resources:{}",JSONUtil.toJSONString(resources)); log.info("List<ProskuInfo> resources:{}",JSONUtil.toJSONString(resources));
for (ProskuInfo resource : resources) { for (ProskuInfo resource : resources) {
@ -211,18 +205,18 @@ public class TbProskuConServiceImpl implements TbProskuConService {
} }
TbProskuCon tbConsInfo1 = new TbProskuCon(); TbProskuCon tbConsInfo1 = new TbProskuCon();
int count = tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConInfoId(), resource.getProductSkuId(), resource.getShopId(), resource.getProductId()); // int count = tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConInfoId(), resource.getProductSkuId(), resource.getShopId(), resource.getProductId());
if (count <= 0) { // if (count <= 0) {
BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true)); // BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1); // newCons.add(tbConsInfo1);
} else { // } else {
StringBuilder strResult = new StringBuilder(product.getName()); // StringBuilder strResult = new StringBuilder(product.getName());
if (sku != null) { // if (sku != null) {
strResult.append(" 规格" + sku.getSpecSnap()); // strResult.append(" 规格" + sku.getSpecSnap());
} // }
strResult.append("与耗材 " + tbConsInfo.getConName() + " 的对应关系已存在"); // strResult.append("与耗材 " + tbConsInfo.getConName() + " 的对应关系已存在");
throw new BadRequestException(strResult.toString()); // throw new BadRequestException(strResult.toString());
} // }
BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1); newCons.add(tbConsInfo1);

View File

@ -11,6 +11,9 @@ import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto; import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria; import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.ViewConInfoFlowMapper; import cn.ysk.cashier.cons.service.mapstruct.ViewConInfoFlowMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@ -22,12 +25,6 @@ import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2024-07-17
**/
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ViewConInfoFlowServiceImpl implements ViewConInfoFlowService { public class ViewConInfoFlowServiceImpl implements ViewConInfoFlowService {
@ -36,7 +33,15 @@ public class ViewConInfoFlowServiceImpl implements ViewConInfoFlowService {
private final ViewConInfoFlowMapper viewConInfoFlowMapper; private final ViewConInfoFlowMapper viewConInfoFlowMapper;
@Override @Override
public Map<String,Object> queryAll(ViewConInfoFlowQueryCriteria criteria, Pageable pageable){ public Map<String,Object> queryAllPage(ViewConInfoFlowQueryCriteria criteria){
Sort sort = Sort.by(Sort.Direction.DESC, "consId");
if(StringUtils.isNotBlank(criteria.getSort())){
String[] sortParams = criteria.getSort().split(",");
String sortField = sortParams[0];
Sort.Direction sortDirection = Sort.Direction.fromString(sortParams[1]);
sort = Sort.by(sortDirection, sortField);
}
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
Page<ViewConInfoFlow> page = viewConInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<ViewConInfoFlow> page = viewConInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(viewConInfoFlowMapper::toDto)); return PageUtil.toPage(page.map(viewConInfoFlowMapper::toDto));
} }

View File

@ -37,8 +37,8 @@ public class TbProductController {
@PostMapping("/list/v2") @PostMapping("/list/v2")
@ApiOperation("查询商品列表 新") @ApiOperation("查询商品列表 新")
public ResponseEntity<Object> queryTbProductV2(@RequestBody TbProductQueryV2Criteria criteria, Pageable pageable){ public ResponseEntity<Object> queryTbProductV2(@RequestBody TbProductQueryV2Criteria criteria){
return new ResponseEntity<>(tbProductService.queryAllV2(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(tbProductService.queryAllV2(criteria),HttpStatus.OK);
} }
@GetMapping("/list") @GetMapping("/list")

View File

@ -67,9 +67,9 @@ public class TbProductQueryV2Criteria {
@Query(type = BETWEEN) @Query(type = BETWEEN)
private List<Long> createdAt; private List<Long> createdAt;
// private Integer page; private Integer page;
// private Integer size;
// private Integer size; private String sort;
public void setType(String type) { public void setType(String type) {
if(StringUtils.isNotBlank(type)){ if(StringUtils.isNotBlank(type)){

View File

@ -241,7 +241,12 @@ public class TbProductServiceImpl implements TbProductService {
} }
@Override @Override
public Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria,Pageable pageable) { public Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria) {
String[] sortParams = criteria.getSort().split(",");
String sortField = sortParams[0];
Sort.Direction sortDirection = Sort.Direction.fromString(sortParams[1]);
Sort sort = Sort.by(sortDirection, sortField);
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
//查询商品数据 //查询商品数据
Page<TbProduct> page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); Page<TbProduct> page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
Integer warnLine = 0; Integer warnLine = 0;

View File

@ -176,6 +176,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
stockDetail.setUnitName(tbShopUnit==null?"":tbShopUnit.getName()); stockDetail.setUnitName(tbShopUnit==null?"":tbShopUnit.getName());
stockDetail.setCreatedAt(System.currentTimeMillis()); stockDetail.setCreatedAt(System.currentTimeMillis());
stockDetail.setUpdatedAt(System.currentTimeMillis()); stockDetail.setUpdatedAt(System.currentTimeMillis());
stockDetail.setOperator(SecurityUtils.getCurrentUsername());
tbProductStockDetailRepository.save(stockDetail); tbProductStockDetailRepository.save(stockDetail);
product.setStockNumber(product.getStockNumber()-stockDetail.getStockNumber().intValue()); product.setStockNumber(product.getStockNumber()-stockDetail.getStockNumber().intValue());
tbProductRepository.save(product); tbProductRepository.save(product);

View File

@ -31,7 +31,7 @@ public interface TbProductService {
Map<String, Object> queryAll(TbProductQueryCriteria criteria, boolean isAdmin); Map<String, Object> queryAll(TbProductQueryCriteria criteria, boolean isAdmin);
Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria, Pageable pageable); Map<String, Object> queryAllV2(TbProductQueryV2Criteria criteria);
/** /**