//package com.sw.mes.yb.production.controller;
//
//import java.util.List;
//import java.util.stream.Collectors;
//
//import javax.servlet.ServletRequest;
//import javax.validation.Valid;
//
//import org.modelmapper.ModelMapper;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Page;
//import org.springframework.data.jpa.domain.Specification;
//import org.springframework.validation.BindingResult;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.sw.mes.core.response.ResponsePage;
//import com.sw.mes.core.response.Result;
//import com.sw.mes.core.response.ResultGenerator;
//import com.sw.mes.core.utils.BeanUtil;
//import com.sw.mes.core.utils.DynamicSpecifications;
//import com.sw.mes.core.utils.PageUtil;
//import com.sw.mes.core.utils.RequestPage;
//import com.sw.mes.yb.production.dto.ResponseTimePage;
//import com.sw.mes.yb.production.dto.TransportInspectTaskDto;
//import com.sw.mes.yb.production.entity.TransportInspectTask;
//import com.sw.mes.yb.production.service.TransportInspectTaskService;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import lombok.extern.slf4j.Slf4j;
//import springfox.documentation.annotations.ApiIgnore;
//
//
///**
//* @Author
//* @Description：
//* @Date: Create in
//* @Modified By:
//*/
//@RestController
//@RequestMapping("/productionTransportInspectTask")
//@Slf4j
//@Api(description = "送验任务接口")
//@Deprecated
//public class TransportInspectTaskController {
//	@Autowired
//	ModelMapper modelMapper;
//
//	@Autowired
//	private TransportInspectTaskService transportInspectTaskService;
//
//	@ApiOperation(value = "分页查询送验任务列表")
//	@ApiImplicitParams({
//		@ApiImplicitParam(name = "rows", value = "行数", dataType = "integer", paramType = "query"),
//		@ApiImplicitParam(name = "page", value = "页码", dataType = "integer", paramType = "query"),
//	})
//	@GetMapping("/listByPage")
//	public Result<ResponseTimePage<TransportInspectTaskDto>> listByPage(ServletRequest request,@ApiIgnore RequestPage requestPage) {
//		Specification<TransportInspectTask> specification = DynamicSpecifications.bySearchFilter(request, TransportInspectTask.class);
//    	Page<TransportInspectTask> page = transportInspectTaskService.findByExample(specification, PageUtil.createPageable(requestPage));
//		List<TransportInspectTaskDto> dtos = page.getContent().stream()
//                .map(entity -> toLazyDto(entity))
//                .collect(Collectors.toList());
//		ResponseTimePage responsePage = new ResponseTimePage(dtos, page.getTotalElements());
//        return ResultGenerator.success(responsePage);
//	}
//
//	@ApiOperation(value = "获取所有送验任务")
//	@GetMapping("/listAll")
//	public Result<List<TransportInspectTaskDto>> listAll(ServletRequest request) {
//		Specification<TransportInspectTask> specification = DynamicSpecifications.bySearchFilter(request, TransportInspectTask.class);
//		List<TransportInspectTask> transportInspectTasks = transportInspectTaskService.findByExampleSort(specification, null);
//		List<TransportInspectTaskDto> transportInspectTaskDtos = transportInspectTasks.stream()
//					.map(transportInspectTask -> toLazyDto(transportInspectTask))
//					.collect(Collectors.toList());
//		return ResultGenerator.success(transportInspectTaskDtos);
//	}
//
//	@ApiOperation(value = "送验任务详细信息")
//	@GetMapping("/{id}")
//	public Result<TransportInspectTaskDto> get(@PathVariable @ApiParam(value="送验任务id") Long id) {
//		TransportInspectTask transportInspectTask = transportInspectTaskService.get(id);
//		if (null == transportInspectTask)
//			return ResultGenerator.fail("该送验任务不存在");
//		return ResultGenerator.success(toEagerDto(transportInspectTask));
//	}
//
//	@ApiOperation(value = "创建送验任务")
//	@PostMapping("/create")
//	public Result create(@RequestBody @Valid @ApiParam(value = "送验任务对象") TransportInspectTaskDto transportInspectTaskDto, BindingResult bindingResult) {
//		if (bindingResult.hasErrors()) {
//			return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
//		}
//		TransportInspectTask transportInspectTask = fromDto(transportInspectTaskDto);
//		transportInspectTaskService.saveOrUpdate(transportInspectTask);
//		return ResultGenerator.success();
//	}
//
//    @ApiOperation(value = "更新送验任务")
//    @PostMapping("/update")
//    public Result update(@RequestBody @Valid @ApiParam(value = "送验任务") TransportInspectTaskDto dto, BindingResult bindingResult) {
//        if (bindingResult.hasErrors())
//            return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
//        if (dto.getId() == null)
//            return ResultGenerator.fail("id不能为空");
//            TransportInspectTask entity = transportInspectTaskService.get(dto.getId());
//        if (entity == null)
//            return ResultGenerator.fail("原信息不存在");
//        try {
//            TransportInspectTask entityfromFto = fromDto(dto);
//			BeanUtils.copyProperties(entityfromFto, entity, BeanUtil.getIgnoreProperties(entityfromFto, null, null));
//			transportInspectTaskService.saveOrUpdate(entity);
//            return ResultGenerator.success();
//        } catch (Exception e) {
//            return ResultGenerator.fail(e.getMessage());
//        }
//    }
//
//	@ApiOperation(value = "删除送验任务")
//	@PostMapping("/delete")
//	public Result remove(@ApiParam(value = "id集合,逗号分隔,如2,4", type = "query") @RequestParam Long[] ids) {
//		for (Long id : ids) {
//				transportInspectTaskService.delete(id);
//		}
//		return ResultGenerator.success();
//	}
//
//	public TransportInspectTaskDto toLazyDto(TransportInspectTask entity) {
//		return modelMapper.map(entity, TransportInspectTaskDto.class);
//	}
//
//	public TransportInspectTaskDto toEagerDto(TransportInspectTask entity) {
//		TransportInspectTaskDto dto = modelMapper.map(entity, TransportInspectTaskDto.class);
//		return dto;
//	}
//
//	public TransportInspectTask fromDto(TransportInspectTaskDto dto) {
//		return modelMapper.map(dto, TransportInspectTask.class);
//	}
//
//
//}
