添加耗材功能

This commit is contained in:
韩鹏辉 2024-07-05 09:49:46 +08:00
parent bdef37b050
commit e3f2d7fc64
8 changed files with 33 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author admin
@ -94,6 +95,14 @@ public class ViewConSku implements Serializable {
@ApiModelProperty(value = "单价")
private String price;
@Column(name = "`create_time`")
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
public void copy(ViewConSku source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -10,4 +10,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @date 2024-06-22
**/
public interface TbConsInfoRepository extends JpaRepository<TbConsInfo, Integer>, JpaSpecificationExecutor<TbConsInfo> {
int countByConCode(String conCode);
}

View File

@ -10,4 +10,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @date 2024-06-22
**/
public interface TbConsTypeRepository extends JpaRepository<TbConsType, Integer>, JpaSpecificationExecutor<TbConsType> {
int countByConTypeCode(String conTypeCode);
}

View File

@ -44,7 +44,7 @@ public class TbConsTypeController {
@PostMapping
@Log("新增耗材类型")
@ApiOperation("新增耗材类型")
public ResponseEntity<Object> createTbConsType(@Validated @RequestBody TbConsType resources){
public ResponseEntity<Object> createTbConsType(@Validated @RequestBody TbConsType resources) throws Exception {
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
return new ResponseEntity<>(tbConsTypeService.create(resources),HttpStatus.CREATED);
}

View File

@ -42,7 +42,7 @@ public interface TbConsTypeService {
* @param resources /
* @return TbConsTypeDto
*/
TbConsTypeDto create(TbConsType resources);
TbConsTypeDto create(TbConsType resources) throws Exception;
/**
* 编辑

View File

@ -18,6 +18,7 @@ package cn.ysk.cashier.cons.service.dto;
import lombok.Data;
import java.math.BigDecimal;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author admin
@ -66,5 +67,7 @@ public class ViewConSkuDto implements Serializable {
private String price;
private Timestamp createTime;
}

View File

@ -97,6 +97,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
throw new Exception("不存在的耗材类型");
}
int count= tbConsInfoRepository.countByConCode(resources.getConCode());
if(count>0){
throw new Exception("耗材代码不允许重复");
}
resources.setConTypeName(tbConsType.getConTypeName());
resources.setLasterInStock(BigDecimal.ZERO);
resources.setStockNumber(BigDecimal.ZERO);

View File

@ -56,7 +56,14 @@ public class TbConsTypeServiceImpl implements TbConsTypeService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbConsTypeDto create(TbConsType resources) {
public TbConsTypeDto create(TbConsType resources) throws Exception {
int count= tbConsTypeRepository.countByConTypeCode(resources.getConTypeCode());
if(count>0){
throw new Exception("耗材类型代码不允许重复");
}
return tbConsTypeMapper.toDto(tbConsTypeRepository.save(resources));
}