Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
e2a127c0d0
|
|
@ -107,6 +107,9 @@ public class TbConsInfo implements Serializable {
|
|||
@ApiModelProperty(value = "是否检测库存")
|
||||
private String isCheck;
|
||||
|
||||
@Transient
|
||||
private String product;
|
||||
|
||||
public void copy(TbConsInfo source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
package cn.ysk.cashier.cons.repository;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -19,4 +23,14 @@ public interface TbConsInfoRepository extends JpaRepository<TbConsInfo, Integer>
|
|||
List<TbConsInfo> findByConTypeId(Integer typeId);
|
||||
|
||||
TbConsInfo findByConCode(String conCode);
|
||||
|
||||
|
||||
@Query(value =
|
||||
"SELECT CONCAT(pro.id, '_', pro.NAME) AS product" +
|
||||
" FROM" +
|
||||
" tb_prosku_con conPro" +
|
||||
" LEFT JOIN tb_product pro ON conPro.product_id = pro.id AND pro.shop_id = :shopId AND conPro.shop_id = :shopId" +
|
||||
" where conPro.con_info_id = :conInfoId " +
|
||||
" group by conPro.product_id ",nativeQuery = true)
|
||||
List<String> queryAllAndPro(@Param("shopId") Integer shopId,@Param("conInfoId")Integer conInfoId);
|
||||
}
|
||||
|
|
@ -47,6 +47,13 @@ public class TbConsInfoController {
|
|||
return new ResponseEntity<>(tbConsInfoService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/allAndPro")
|
||||
@ApiOperation("耗材列表(携带商品信息)")
|
||||
public ResponseEntity<Object> queryAllAndPro(TbConsInfoQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbConsInfoService.queryAllAndPro(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增耗材信息")
|
||||
@ApiOperation("新增耗材信息")
|
||||
|
|
|
|||
|
|
@ -1,63 +1,63 @@
|
|||
package cn.ysk.cashier.cons.rest;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
|
||||
import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "获取耗材流水信息管理")
|
||||
@RequestMapping("/api/viewConInfoFlow")
|
||||
public class ViewConInfoFlowController {
|
||||
|
||||
private final ViewConInfoFlowService viewConInfoFlowService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportViewConInfoFlow(HttpServletResponse response, ViewConInfoFlowQueryCriteria criteria) throws IOException {
|
||||
viewConInfoFlowService.download(viewConInfoFlowService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@PostMapping("get")
|
||||
@ApiOperation("查询获取耗材流水信息")
|
||||
public ResponseEntity<Object> queryViewConInfoFlow(@RequestBody ViewConInfoFlowQueryCriteria criteria){
|
||||
return new ResponseEntity<>(viewConInfoFlowService.queryAllPage(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增获取耗材流水信息")
|
||||
@ApiOperation("新增获取耗材流水信息")
|
||||
public ResponseEntity<Object> createViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
|
||||
return new ResponseEntity<>(viewConInfoFlowService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改获取耗材流水信息")
|
||||
@ApiOperation("修改获取耗材流水信息")
|
||||
public ResponseEntity<Object> updateViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
|
||||
viewConInfoFlowService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除获取耗材流水信息")
|
||||
@ApiOperation("删除获取耗材流水信息")
|
||||
public ResponseEntity<Object> deleteViewConInfoFlow(@RequestBody Integer[] ids) {
|
||||
viewConInfoFlowService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
//package cn.ysk.cashier.cons.rest;
|
||||
//
|
||||
//import cn.ysk.cashier.annotation.Log;
|
||||
//import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
|
||||
//import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
|
||||
//import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.http.HttpStatus;
|
||||
//import org.springframework.http.ResponseEntity;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import io.swagger.annotations.*;
|
||||
//import java.io.IOException;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
///**
|
||||
//* @author admin
|
||||
//* @date 2024-07-17
|
||||
//**/
|
||||
//@RestController
|
||||
//@RequiredArgsConstructor
|
||||
//@Api(tags = "获取耗材流水信息管理")
|
||||
//@RequestMapping("/api/viewConInfoFlow")
|
||||
//public class ViewConInfoFlowController {
|
||||
//
|
||||
// private final ViewConInfoFlowService viewConInfoFlowService;
|
||||
//
|
||||
// @Log("导出数据")
|
||||
// @ApiOperation("导出数据")
|
||||
// @GetMapping(value = "/download")
|
||||
// public void exportViewConInfoFlow(HttpServletResponse response, ViewConInfoFlowQueryCriteria criteria) throws IOException {
|
||||
// viewConInfoFlowService.download(viewConInfoFlowService.queryAll(criteria), response);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("get")
|
||||
// @ApiOperation("查询获取耗材流水信息")
|
||||
// public ResponseEntity<Object> queryViewConInfoFlow(@RequestBody ViewConInfoFlowQueryCriteria criteria){
|
||||
// return new ResponseEntity<>(viewConInfoFlowService.queryAllPage(criteria),HttpStatus.OK);
|
||||
// }
|
||||
//
|
||||
// @PostMapping
|
||||
// @Log("新增获取耗材流水信息")
|
||||
// @ApiOperation("新增获取耗材流水信息")
|
||||
// public ResponseEntity<Object> createViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
|
||||
// return new ResponseEntity<>(viewConInfoFlowService.create(resources),HttpStatus.CREATED);
|
||||
// }
|
||||
//
|
||||
// @PutMapping
|
||||
// @Log("修改获取耗材流水信息")
|
||||
// @ApiOperation("修改获取耗材流水信息")
|
||||
// public ResponseEntity<Object> updateViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
|
||||
// viewConInfoFlowService.update(resources);
|
||||
// return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
// }
|
||||
//
|
||||
// @DeleteMapping
|
||||
// @Log("删除获取耗材流水信息")
|
||||
// @ApiOperation("删除获取耗材流水信息")
|
||||
// public ResponseEntity<Object> deleteViewConInfoFlow(@RequestBody Integer[] ids) {
|
||||
// viewConInfoFlowService.deleteAll(ids);
|
||||
// return new ResponseEntity<>(HttpStatus.OK);
|
||||
// }
|
||||
//}
|
||||
|
|
@ -28,6 +28,8 @@ public interface TbConsInfoService {
|
|||
*/
|
||||
Map<String,Object> queryAll(TbConsInfoQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
Map<String, Object> queryAllAndPro(TbConsInfoQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
|
|
|
|||
|
|
@ -80,4 +80,6 @@ public class TbConsInfoDto implements Serializable {
|
|||
|
||||
|
||||
private String isCheck;
|
||||
|
||||
private String product;
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package cn.ysk.cashier.cons.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
|
||||
|
|
@ -33,4 +35,12 @@ public class TbConsInfoQueryCriteria{
|
|||
|
||||
@Query
|
||||
private String status;
|
||||
|
||||
@Query(type = Query.Type.IN)
|
||||
private List<Timestamp> createTimes;
|
||||
|
||||
|
||||
private Integer page=0;
|
||||
private Integer size=10;
|
||||
private String sort;
|
||||
}
|
||||
|
|
@ -1,5 +1,19 @@
|
|||
package cn.ysk.cashier.cons.service.impl;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Subquery;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import org.springframework.data.domain.*;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.cons.domain.*;
|
||||
import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository;
|
||||
|
|
@ -25,16 +39,20 @@ import com.alibaba.fastjson.JSONArray;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.persistence.criteria.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -72,10 +90,29 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TbConsInfoDto> queryAll(TbConsInfoQueryCriteria criteria) {
|
||||
public Map<String, Object> queryAllAndPro(TbConsInfoQueryCriteria 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<TbConsInfo> page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
Page<TbConsInfoDto> result = page.map(tbConsInfoMapper::toDto);
|
||||
result.getContent().forEach(it -> {
|
||||
List<String> list = tbConsInfoRepository.queryAllAndPro(criteria.getShopId(), it.getId());
|
||||
it.setProduct(String.join(",", list));
|
||||
});
|
||||
return PageUtil.toPage(result);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TbConsInfoDto> queryAll(TbConsInfoQueryCriteria criteria) {
|
||||
List<TbConsInfoDto> list = tbConsInfoMapper.toDto(tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||
if (Objects.nonNull(list) && !list.isEmpty()) {
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.parallelStream().forEach(it -> it.setContypeCode(tbConsTypeRepository.findById(it.getConTypeId()).orElseGet(TbConsType::new).getConTypeCode()));
|
||||
}
|
||||
return list;
|
||||
|
|
@ -104,35 +141,20 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
// if (count > 0) {
|
||||
// throw new Exception("耗材代码不允许重复");
|
||||
// }
|
||||
|
||||
|
||||
if(StringUtils.isBlank(resource.getConUnit())){
|
||||
throw new Exception(resource.getConName()+ "的单位不允许为空");
|
||||
}
|
||||
resource.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER));
|
||||
resource.setConTypeName(tbConsType.getConTypeName());
|
||||
resource.setLasterInStock(BigDecimal.ZERO);
|
||||
resource.setStockNumber(BigDecimal.ZERO);
|
||||
resource.setIsCheck("0");
|
||||
resource.setStatus("1");
|
||||
resource.setStockConsume(BigDecimal.ZERO);
|
||||
resource.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
resource = tbConsInfoRepository.save(resource);
|
||||
|
||||
|
||||
TbConsInfoFlow flow = new TbConsInfoFlow();
|
||||
|
||||
flow.setBizCode("stockIn");
|
||||
flow.setBizName("初始化入库");
|
||||
flow.setBizType("+");
|
||||
flow.setConsId(resource.getId());
|
||||
flow.setShopId(resource.getShopId());
|
||||
flow.setConName(resource.getConName());
|
||||
flow.setAmount(BigDecimal.ZERO);
|
||||
flow.setBalance(BigDecimal.ZERO);
|
||||
flow.setOperator(SecurityUtils.getCurrentUsername());
|
||||
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
tbConsInfoFlowRepository.save(flow);
|
||||
|
||||
|
||||
tbConsInfoRepository.save(resource);
|
||||
}
|
||||
return tbConsInfoMapper.toDto(new TbConsInfo());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -144,13 +166,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
if (Objects.isNull(tbConsInfo)) {
|
||||
throw new Exception("耗材信息不存在");
|
||||
}
|
||||
|
||||
tbConsInfo.setConName(ObjectUtil.isEmpty(resource.getConName())||ObjectUtil.isNull(resource.getConName())?tbConsInfo.getConName():resource.getConName());
|
||||
tbConsInfo.setPrice(ObjectUtil.isEmpty(resource.getPrice())||ObjectUtil.isNull(resource.getPrice())?tbConsInfo.getPrice():resource.getPrice());
|
||||
tbConsInfo.setConUnit(ObjectUtil.isEmpty(resource.getConUnit())||ObjectUtil.isNull(resource.getConUnit())?tbConsInfo.getConUnit(): resource.getConUnit());
|
||||
tbConsInfo.setConWarning(ObjectUtil.isEmpty(resource.getConWarning())||ObjectUtil.isNull(resource.getConWarning())?tbConsInfo.getConWarning():resource.getConWarning());
|
||||
tbConsInfo.setStatus(ObjectUtil.isEmpty(resource.getStatus())||ObjectUtil.isNull(resource.getStatus())?tbConsInfo.getStatus():resource.getStatus());
|
||||
tbConsInfo.setIsCheck(ObjectUtil.isEmpty(resource.getIsCheck())||ObjectUtil.isNull(resource.getIsCheck())?tbConsInfo.getIsCheck():resource.getIsCheck());
|
||||
BeanUtil.copyProperties(resource,tbConsInfo, CopyOptions.create().setIgnoreNullValue(true));
|
||||
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
tbConsInfoRepository.save(tbConsInfo);
|
||||
|
|
@ -274,7 +290,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
else if ("out".equals(resources.getType())) {
|
||||
stockOperate.setSubType(-1);
|
||||
|
||||
if (conInfos.getStockNumber().compareTo(info.getStockNumber()) > 0) {
|
||||
if (conInfos.getStockNumber().compareTo(info.getStockNumber().subtract(info.getStockConsume())) > 0) {
|
||||
throw new BadRequestException("出库数量大于现有的库存数量");
|
||||
}
|
||||
|
||||
|
|
@ -512,8 +528,4 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue