新增物料信息

pull/451/head
starrysky 2019-08-24 16:28:27 +08:00
parent ff5ec90246
commit a7e80e0ed7
5 changed files with 47 additions and 4 deletions

View File

@ -48,9 +48,15 @@ public class MaterialCategoryController {
return new ResponseEntity(HttpStatus.OK);
}
@Log("查询物料类别")
@Log("分页查询物料类别")
@GetMapping(value = "/queryMaterialCategoryPage")
public ResponseEntity queryMaterialCategoryPage(MaterialCategoryDTO resources, Pageable pageable){
return new ResponseEntity(materialCategoryService.queryAll(resources,pageable),HttpStatus.OK);
}
@Log("查询物料类别")
@GetMapping(value = "/queryMaterialCategoryList")
public ResponseEntity queryMaterialCategoryList(MaterialCategoryDTO resources){
return new ResponseEntity(materialCategoryService.queryAll(resources),HttpStatus.OK);
}
}

View File

@ -14,6 +14,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author
* @date 2019-07-27
@ -25,6 +28,15 @@ public class MaterialInfoController {
@Autowired
private MaterialInfoService materialInfoService;
@Log("初始化物料资料编号")
@ApiOperation(value = "初始化物料资料编号")
@GetMapping(value = "/initMaterialInfoCode")
@PreAuthorize("hasAnyRole('ADMIN','BDSUPPLIERINFO_ALL','BDSUPPLIERINFO_SELECT')")
public ResponseEntity initMaterialInfoCode(){
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");//设置日期格式
String supplierCode = "WL"+ LocalDateTime.now().format(fmt);
return new ResponseEntity(supplierCode,HttpStatus.OK);
}
@Log("分页查询物料资料")
@ApiOperation(value = "分页查询物料资料")
@ -58,14 +70,14 @@ public class MaterialInfoController {
@Log("删除物料资料")
@ApiOperation(value = "删除物料资料")
@DeleteMapping(value = "/materialInfo/{id}")
public ResponseEntity delete(@PathVariable Integer id){
public ResponseEntity deleteMaterialInfoById(@PathVariable Integer id){
materialInfoService.delete(id);
return new ResponseEntity(HttpStatus.OK);
}
@Log("查看物料资料详情")
@GetMapping(value = "/materialInfo/{id}")
public ResponseEntity getMaterialInfo(@PathVariable Long id){
public ResponseEntity getMaterialInfoById(@PathVariable Long id){
return new ResponseEntity(materialInfoService.findById(id), HttpStatus.OK);
}
}

View File

@ -53,7 +53,7 @@ public class ProductInfoController {
@Log("查询产品资料列表")
@ApiOperation(value = "查询产品资料列表")
@GetMapping(value = "/productInfo/all")
@GetMapping(value = "/queryProductInfoList")
public ResponseEntity queryProductInfoList(ProductInfoQueryCriteria criteria){
return new ResponseEntity(productInfoService.queryAll(criteria),HttpStatus.OK);
}

View File

@ -17,4 +17,6 @@ public interface MaterialCategoryService {
void delete(Long id);
Object queryAll(MaterialCategoryDTO materialCategory, Pageable pageable);
Object queryAll(MaterialCategoryDTO materialCategory);
}

View File

@ -106,4 +106,27 @@ public class MaterialCategoryServiceImpl implements MaterialCategoryService {
return PageUtil.toPage(page.map(materialCategoryMapper::toDto));
}
@Override
public Object queryAll(MaterialCategoryDTO materialCategory) {
Specification<MaterialCategory> specification = new Specification<MaterialCategory>() {
@Override
public Predicate toPredicate(Root<MaterialCategory> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();
//状态
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate);
if(CollectionUtils.isEmpty(targetPredicateList)){
return null;
}else{
return criteriaBuilder.and(targetPredicateList.toArray(new Predicate[targetPredicateList.size()]));
}
}
};
List<MaterialCategory> materialCategoryList = materialCategoryRepository.findAll(specification);
return materialCategoryMapper.toDto(materialCategoryList);
}
}