mirror of https://github.com/elunez/eladmin
新增删除物料资料
parent
e07d04e1ba
commit
1b116ca132
|
@ -0,0 +1,28 @@
|
|||
package me.zhengjie.modules.wms.bd.cons;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料库存预警信息
|
||||
* [{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,”minimum_inventory”:””,”highest_inventory”:””}]
|
||||
* @author 黄星星
|
||||
* @date 2019-07-28
|
||||
*/
|
||||
@Data
|
||||
public class MaterialInventoryWarning {
|
||||
// 排序
|
||||
private Integer sort;
|
||||
|
||||
// 仓库编码
|
||||
private String wareHouseCode;
|
||||
|
||||
// 仓库名称
|
||||
private String wareHouseName;
|
||||
|
||||
// 最低库存
|
||||
private Integer miniNumInventory;
|
||||
|
||||
// 最高库存
|
||||
private Integer highestInventory;
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.bean.copier.CopyOptions;
|
|||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -69,6 +70,9 @@ public class MaterialInfo implements Serializable {
|
|||
@Column(name = "material_initial_setup_total_number")
|
||||
private String materialInitialSetupTotalNumber;
|
||||
|
||||
@NotNull
|
||||
private Boolean status;
|
||||
|
||||
// 创建时间
|
||||
@Column(name = "create_time")
|
||||
@CreationTimestamp
|
||||
|
|
|
@ -1,12 +1,37 @@
|
|||
package me.zhengjie.modules.wms.bd.repository;
|
||||
|
||||
import me.zhengjie.modules.wms.bd.domain.MaterialCategory;
|
||||
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @author 黄星星
|
||||
* @date 2019-07-27
|
||||
*/
|
||||
public interface MaterialInfoRepository extends JpaRepository<MaterialInfo, Long>, JpaSpecificationExecutor {
|
||||
|
||||
/**
|
||||
* 根据物料编码查询状态存在的物料资料
|
||||
* @param materialCode
|
||||
* @return
|
||||
*/
|
||||
MaterialInfo findByMaterialCodeAndStatusTrue(String materialCode);
|
||||
|
||||
/**
|
||||
* 根据主键查询状态正常的物料资料
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
MaterialInfo findByIdAndStatusTrue(long id);
|
||||
|
||||
/**
|
||||
* 删除物料资料
|
||||
* @param id
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "update bd_material_info set status = 0 where id = ?1",nativeQuery = true)
|
||||
void deleteMaterialInfo(long id);
|
||||
}
|
|
@ -85,6 +85,13 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
|
|||
if(null == measureUnit){
|
||||
throw new BadRequestException("计量单位不存在!");
|
||||
}
|
||||
|
||||
// 物料编码
|
||||
String materialCode = resources.getMaterialCode();
|
||||
MaterialInfo byMaterialCodeAndStatusTrue = materialInfoRepository.findByMaterialCodeAndStatusTrue(materialCode);
|
||||
if(null != byMaterialCodeAndStatusTrue){
|
||||
throw new BadRequestException("物料编码已存在!");
|
||||
}
|
||||
return materialInfoMapper.toDto(materialInfoRepository.save(resources));
|
||||
}
|
||||
|
||||
|
@ -101,6 +108,10 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(long id) {
|
||||
materialInfoRepository.deleteById(id);
|
||||
MaterialInfo materialInfo = materialInfoRepository.findByIdAndStatusTrue(id);
|
||||
if(null == materialInfo){
|
||||
throw new BadRequestException("物料资料不存在!");
|
||||
}
|
||||
materialInfoRepository.deleteMaterialInfo(id);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue