From e12c948b3ba0a07f98bd52c5c0ec4ae5404c643c Mon Sep 17 00:00:00 2001 From: anthonywj Date: Mon, 29 May 2023 17:57:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=BD=E6=BA=AF=E4=BB=A3=E7=A0=81=E5=A4=87?= =?UTF-8?q?=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trace/TraceOrderController.java | 15 --- .../controller/trace/UdiTraceController.java | 105 ++++++++++++++++-- .../glxp/api/entity/trace/MqTraceMessage.java | 2 +- .../entity/trace/TraceTaskNoticeEntity.java | 6 + 4 files changed, 102 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/trace/TraceOrderController.java b/src/main/java/com/glxp/api/controller/trace/TraceOrderController.java index cce70da..74bf599 100644 --- a/src/main/java/com/glxp/api/controller/trace/TraceOrderController.java +++ b/src/main/java/com/glxp/api/controller/trace/TraceOrderController.java @@ -46,20 +46,5 @@ public class TraceOrderController extends BaseController { } - //客户端出入库单据上传接口 - @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("上传成功"); - } - } diff --git a/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java b/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java index b742710..435518b 100644 --- a/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java +++ b/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java @@ -2,24 +2,27 @@ package com.glxp.api.controller.trace; import cn.hutool.core.util.IdUtil; 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.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.entity.trace.TraceProductDetailEntity; -import com.glxp.api.entity.trace.TraceRecordLogEntity; -import com.glxp.api.entity.trace.TraceTaskNoticeEntity; +import com.glxp.api.entity.trace.*; +import com.glxp.api.req.trace.TraceOrderUploadRequest; import com.glxp.api.req.trace.TraceRecordRequest; import com.glxp.api.res.basic.BasicUdiRelResponse; import com.glxp.api.service.basic.BasicUdiRelService; -import com.glxp.api.service.trace.TraceProductDetailService; -import com.glxp.api.service.trace.TraceRecordService; +import com.glxp.api.service.trace.*; import com.glxp.api.util.GennerOrderUtils; import com.glxp.api.util.udi.FilterUdiUtils; 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.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; @@ -41,6 +44,13 @@ public class UdiTraceController extends BaseController { BasicUdiRelService basicUdiRelService; @Resource GennerOrderUtils gennerOrderUtils; + @Resource + TraceTaskNoticeService traceTaskNoticeService; + @Resource + RabbitPushService rabbitPushService; + @Resource + TraceOrderService traceOrderService; + /** * 源头追溯查询 @@ -107,25 +117,57 @@ public class UdiTraceController extends BaseController { traceProductDetailService.save(traceProductDetailEntity); } } 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.创建查询任务表 TraceTaskNoticeEntity traceTaskNoticeEntity = new TraceTaskNoticeEntity(); 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()); List diList = basicUdiRelService.getBaseMapper().findDiList(basicUdiRelResponse.getUuid()); traceTaskNoticeEntity.setDiList(diList); 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.error(500, "请选择查询方式!"); + return ResultVOUtils.success("创建查询成功,请稍后刷新查看查询结果!"); } + 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("上传成功"); + } + } diff --git a/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java b/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java index 27bdfa9..f49ce4a 100644 --- a/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java +++ b/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java @@ -18,7 +18,7 @@ public class MqTraceMessage { /** * 报备企业统一社会信用号 */ - private Long cerditNo; + private String cerditNo; /** * 任务类型 1:提交生产信息和出入库信息;2:提交出入库信息 diff --git a/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java b/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java index a28db79..70ecfb8 100644 --- a/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java +++ b/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java @@ -74,6 +74,12 @@ public class TraceTaskNoticeEntity implements Serializable { @TableField(value = "batchNo") private String batchNo; + /** + * 生产日期 + */ + @TableField(value = "produceDate") + private String produceDate; + /** * 失效日期 */