|  |  | @ -2,24 +2,27 @@ package com.glxp.api.controller.trace; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.util.IdUtil; |  |  |  | import cn.hutool.core.util.IdUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.annotation.AuthRuleAnnotation; |  |  |  | import com.glxp.api.annotation.AuthRuleAnnotation; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.common.enums.ResultEnum; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.res.BaseResponse; |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.util.ResultVOUtils; |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.constant.Constant; |  |  |  | import com.glxp.api.constant.Constant; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.controller.BaseController; |  |  |  | import com.glxp.api.controller.BaseController; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.basic.UdiEntity; |  |  |  | import com.glxp.api.entity.basic.UdiEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.sup.UserCompanyEntity; |  |  |  | import com.glxp.api.entity.sup.UserCompanyEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.trace.TraceProductDetailEntity; |  |  |  | import com.glxp.api.entity.trace.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.trace.TraceRecordLogEntity; |  |  |  | import com.glxp.api.req.trace.TraceOrderUploadRequest; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.trace.TraceTaskNoticeEntity; |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.trace.TraceRecordRequest; |  |  |  | import com.glxp.api.req.trace.TraceRecordRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.basic.BasicUdiRelResponse; |  |  |  | import com.glxp.api.res.basic.BasicUdiRelResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.BasicUdiRelService; |  |  |  | import com.glxp.api.service.basic.BasicUdiRelService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.trace.TraceProductDetailService; |  |  |  | import com.glxp.api.service.trace.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.trace.TraceRecordService; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.GennerOrderUtils; |  |  |  | import com.glxp.api.util.GennerOrderUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.udi.FilterUdiUtils; |  |  |  | import com.glxp.api.util.udi.FilterUdiUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lombok.extern.slf4j.Slf4j; |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.springframework.validation.BindingResult; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.web.bind.annotation.GetMapping; |  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.web.bind.annotation.RestController; |  |  |  | import org.springframework.web.bind.annotation.RestController; | 
			
		
	
		
		
			
				
					
					|  |  |  | import springfox.documentation.annotations.ApiIgnore; |  |  |  | import springfox.documentation.annotations.ApiIgnore; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -41,6 +44,13 @@ public class UdiTraceController extends BaseController { | 
			
		
	
		
		
			
				
					
					|  |  |  |     BasicUdiRelService basicUdiRelService; |  |  |  |     BasicUdiRelService basicUdiRelService; | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Resource |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |     GennerOrderUtils gennerOrderUtils; |  |  |  |     GennerOrderUtils gennerOrderUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     TraceTaskNoticeService traceTaskNoticeService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     RabbitPushService rabbitPushService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     TraceOrderService traceOrderService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * 源头追溯查询 |  |  |  |      * 源头追溯查询 | 
			
		
	
	
		
		
			
				
					|  |  | @ -107,25 +117,57 @@ public class UdiTraceController extends BaseController { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     traceProductDetailService.save(traceProductDetailEntity); |  |  |  |                     traceProductDetailService.save(traceProductDetailEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else {    //按批次号查询
 |  |  |  |             } else {    //按批次号查询
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                 traceProductDetailEntity = traceProductDetailService.findUniqueByData(1, traceRecordRequest.getYlqxzcrbarmc(), | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         traceRecordRequest.getCpmctymc(), traceRecordRequest.getGgxh(), traceRecordRequest.getNameCode(), traceRecordRequest.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (traceProductDetailEntity == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setTraceSource(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setTraceType(traceRecordRequest.getTraceType()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setYlqxzcrbarmc(basicUdiRelResponse.getYlqxzcrbarmc()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setCreditNum(basicUdiRelResponse.getTyshxydm()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setCpmctymc(basicUdiRelResponse.getCpmctymc()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setGgxh(basicUdiRelResponse.getGgxh()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setNameCode(basicUdiRelResponse.getNameCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setBatchNo(traceRecordRequest.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailEntity.setStatus(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     traceProductDetailService.save(traceProductDetailEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             //5.创建查询任务表
 |  |  |  |             //5.创建查询任务表
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             TraceTaskNoticeEntity traceTaskNoticeEntity = new TraceTaskNoticeEntity(); |  |  |  |             TraceTaskNoticeEntity traceTaskNoticeEntity = new TraceTaskNoticeEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             traceTaskNoticeEntity.setId(IdUtil.getSnowflakeNextId()); |  |  |  |             traceTaskNoticeEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setRecordCode(traceRecordLogEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setTaskType(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setStatus(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setCompanyIdFk(basicUdiRelResponse.getCompanyIdFk()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setYlqxzcrbarmc(basicUdiRelResponse.getYlqxzcrbarmc()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setCreditNum(basicUdiRelResponse.getTyshxydm()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setCpmctymc(basicUdiRelResponse.getCpmctymc()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setGgxh(basicUdiRelResponse.getGgxh()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setBatchNo(udiEntity.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setProduceDate(udiEntity.getProduceDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setExpireDate(udiEntity.getExpireDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             traceTaskNoticeEntity.setSerialNo(udiEntity.getSerialNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             traceTaskNoticeEntity.setCreateTime(new Date()); |  |  |  |             traceTaskNoticeEntity.setCreateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             List<String> diList = basicUdiRelService.getBaseMapper().findDiList(basicUdiRelResponse.getUuid()); |  |  |  |             List<String> diList = basicUdiRelService.getBaseMapper().findDiList(basicUdiRelResponse.getUuid()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             traceTaskNoticeEntity.setDiList(diList); |  |  |  |             traceTaskNoticeEntity.setDiList(diList); | 
			
		
	
		
		
			
				
					
					|  |  |  |             traceTaskNoticeEntity.setTaskType(1); |  |  |  |             traceTaskNoticeEntity.setTaskType(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |             traceTaskNoticeEntity.setStatus(1); |  |  |  |             traceTaskNoticeService.save(traceTaskNoticeEntity); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else if (traceRecordRequest.getTraceType() == Constant.UDI_BATCHNO) { |  |  |  |             //6.构建MQ推送消息
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             MqTraceMessage mqTraceMessage = new MqTraceMessage(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             mqTraceMessage.setCreateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             mqTraceMessage.setTaskType(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             mqTraceMessage.setCompanyId(basicUdiRelResponse.getCompanyIdFk()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             mqTraceMessage.setCerditNo(userCompanyEntity.getCreditNum()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             rabbitPushService.send(mqTraceMessage); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |             return ResultVOUtils.success("创建查询成功,请稍后刷新查看查询结果!"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             return ResultVOUtils.error(500, "请选择查询方式!"); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         return ResultVOUtils.error(500, "查询失败"); |  |  |  |         return ResultVOUtils.error(500, "查询失败"); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -151,4 +193,47 @@ public class UdiTraceController extends BaseController { | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 客户端根据任务上传出入库单据 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param traceOrderUploadRequest | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param bindingResult | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @AuthRuleAnnotation("udi/trace/order/upload") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @PostMapping("udi/trace/order/upload") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public BaseResponse uploadOrder(@RequestBody TraceOrderUploadRequest traceOrderUploadRequest, BindingResult bindingResult) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (bindingResult.hasErrors()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         TraceOrderEntity traceOrderEntity = new TraceOrderEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         BeanUtils.copyProperties(traceOrderUploadRequest, traceOrderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         traceOrderEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         traceOrderEntity.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         traceOrderService.save(traceOrderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return ResultVOUtils.success("上传成功"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 客户端根据任务上传生产关联关系信息 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param traceOrderUploadRequest | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param bindingResult | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @AuthRuleAnnotation("udi/trace/manuOrder/upload") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @PostMapping("udi/trace/manuOrder/upload") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public BaseResponse uploadManuOrder(@RequestBody TraceOrderUploadRequest traceOrderUploadRequest, BindingResult bindingResult) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (bindingResult.hasErrors()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         TraceOrderEntity traceOrderEntity = new TraceOrderEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         BeanUtils.copyProperties(traceOrderUploadRequest, traceOrderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         traceOrderEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         traceOrderEntity.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         traceOrderService.save(traceOrderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return ResultVOUtils.success("上传成功"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |