|
|
|
package com.glxp.api.controller.trace;
|
|
|
|
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
import com.glxp.api.controller.BaseController;
|
|
|
|
import com.glxp.api.entity.basic.UdiEntity;
|
|
|
|
import com.glxp.api.entity.sup.UserCompanyEntity;
|
|
|
|
import com.glxp.api.req.trace.TraceRecordRequest;
|
|
|
|
import com.glxp.api.service.basic.BasicUdiRelService;
|
|
|
|
import com.glxp.api.service.trace.TraceRecordService;
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
@ApiIgnore
|
|
|
|
@RestController
|
|
|
|
@Slf4j
|
|
|
|
public class UdiTraceController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
TraceRecordService traceRecordService;
|
|
|
|
@Resource
|
|
|
|
BasicUdiRelService basicUdiRelService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 源头追溯查询
|
|
|
|
*
|
|
|
|
* @param traceRecordRequest
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AuthRuleAnnotation("udi/trace/source/search")
|
|
|
|
@GetMapping("udi/trace/source/search")
|
|
|
|
public BaseResponse createTrace(TraceRecordRequest traceRecordRequest) {
|
|
|
|
|
|
|
|
|
|
|
|
if (traceRecordRequest.getTraceType() == Constant.UDI_TRACE) {
|
|
|
|
|
|
|
|
//1.校验UDI码格式
|
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(traceRecordRequest.getUdiCode());
|
|
|
|
if (udiEntity == null) {
|
|
|
|
return ResultVOUtils.error(500, "UDI码格式错误");
|
|
|
|
}
|
|
|
|
|
|
|
|
//2.查询源头企业
|
|
|
|
UserCompanyEntity userCompanyEntity = basicUdiRelService.findByNameCode(udiEntity.getUdi());
|
|
|
|
if (userCompanyEntity == null) {
|
|
|
|
return ResultVOUtils.error(500, "生产企业未关联该产品信息!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (traceRecordRequest.getTraceType() == Constant.UDI_BATCHNO) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return ResultVOUtils.error(500, "请选择查询方式!");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(500, "查询失败");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 现场检查查询
|
|
|
|
*
|
|
|
|
* @param traceRecordRequest
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AuthRuleAnnotation("udi/trace/scene/search")
|
|
|
|
@GetMapping("udi/trace/scene/search")
|
|
|
|
public BaseResponse sceneTrace(TraceRecordRequest traceRecordRequest) {
|
|
|
|
|
|
|
|
if (traceRecordRequest.getTraceType() == Constant.UDI_TRACE) {
|
|
|
|
|
|
|
|
} else if (traceRecordRequest.getTraceType() == Constant.UDI_BATCHNO) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return ResultVOUtils.error(500, "请选择查询方式!");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(500, "查询失败");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|