新增删除物料资料

pull/451/head
starrysky 2019-07-28 10:59:32 +08:00
parent e07d04e1ba
commit 1b116ca132
4 changed files with 69 additions and 1 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}
}