添加耗材功能
This commit is contained in:
@@ -23,6 +23,7 @@ import javax.persistence.*;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author admin
|
* @author admin
|
||||||
@@ -94,6 +95,14 @@ public class ViewConSku implements Serializable {
|
|||||||
@ApiModelProperty(value = "单价")
|
@ApiModelProperty(value = "单价")
|
||||||
private String price;
|
private String price;
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "`create_time`")
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void copy(ViewConSku source){
|
public void copy(ViewConSku source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
* @date 2024-06-22
|
* @date 2024-06-22
|
||||||
**/
|
**/
|
||||||
public interface TbConsInfoRepository extends JpaRepository<TbConsInfo, Integer>, JpaSpecificationExecutor<TbConsInfo> {
|
public interface TbConsInfoRepository extends JpaRepository<TbConsInfo, Integer>, JpaSpecificationExecutor<TbConsInfo> {
|
||||||
|
|
||||||
|
|
||||||
|
int countByConCode(String conCode);
|
||||||
}
|
}
|
||||||
@@ -10,4 +10,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
* @date 2024-06-22
|
* @date 2024-06-22
|
||||||
**/
|
**/
|
||||||
public interface TbConsTypeRepository extends JpaRepository<TbConsType, Integer>, JpaSpecificationExecutor<TbConsType> {
|
public interface TbConsTypeRepository extends JpaRepository<TbConsType, Integer>, JpaSpecificationExecutor<TbConsType> {
|
||||||
|
|
||||||
|
int countByConTypeCode(String conTypeCode);
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public class TbConsTypeController {
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
@Log("新增耗材类型")
|
@Log("新增耗材类型")
|
||||||
@ApiOperation("新增耗材类型")
|
@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()));
|
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
return new ResponseEntity<>(tbConsTypeService.create(resources),HttpStatus.CREATED);
|
return new ResponseEntity<>(tbConsTypeService.create(resources),HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public interface TbConsTypeService {
|
|||||||
* @param resources /
|
* @param resources /
|
||||||
* @return TbConsTypeDto
|
* @return TbConsTypeDto
|
||||||
*/
|
*/
|
||||||
TbConsTypeDto create(TbConsType resources);
|
TbConsTypeDto create(TbConsType resources) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package cn.ysk.cashier.cons.service.dto;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author admin
|
* @author admin
|
||||||
@@ -66,5 +67,7 @@ public class ViewConSkuDto implements Serializable {
|
|||||||
|
|
||||||
private String price;
|
private String price;
|
||||||
|
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -97,6 +97,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
throw new Exception("不存在的耗材类型");
|
throw new Exception("不存在的耗材类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int count= tbConsInfoRepository.countByConCode(resources.getConCode());
|
||||||
|
if(count>0){
|
||||||
|
throw new Exception("耗材代码不允许重复");
|
||||||
|
}
|
||||||
resources.setConTypeName(tbConsType.getConTypeName());
|
resources.setConTypeName(tbConsType.getConTypeName());
|
||||||
resources.setLasterInStock(BigDecimal.ZERO);
|
resources.setLasterInStock(BigDecimal.ZERO);
|
||||||
resources.setStockNumber(BigDecimal.ZERO);
|
resources.setStockNumber(BigDecimal.ZERO);
|
||||||
|
|||||||
@@ -56,7 +56,14 @@ public class TbConsTypeServiceImpl implements TbConsTypeService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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));
|
return tbConsTypeMapper.toDto(tbConsTypeRepository.save(resources));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user