From 2f041270fdc83ea524b34afbc5f8d0f50b0e81ee Mon Sep 17 00:00:00 2001 From: anthonywj Date: Sun, 30 Jul 2023 11:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BD=93=E5=89=8D=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trace/TraceRecordController.java | 26 ++++++++++++++++++- .../controller/trace/UdiTraceController.java | 11 ++++---- .../trace/TraceProductDetailEntity.java | 6 +++++ .../api/res/trace/TraceOrderResponse.java | 3 +++ .../api/service/trace/UdiTraceService.java | 6 +++-- .../mybatis/mapper/trace/TraceOrderMapper.xml | 1 + src/main/resources/schemas/schema_v2.1.sql | 3 +++ 7 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java b/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java index bbf0f42..f084f69 100644 --- a/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java +++ b/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java @@ -10,8 +10,10 @@ import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.config.rabbit.TopicRabbitConfig; import com.glxp.api.controller.BaseController; +import com.glxp.api.entity.sup.UserCompanyEntity; import com.glxp.api.entity.trace.TraceManuOrderEntity; import com.glxp.api.entity.trace.TraceOrderEntity; +import com.glxp.api.entity.trace.TraceProductDetailEntity; import com.glxp.api.entity.trace.TraceRecordLogEntity; import com.glxp.api.req.trace.TraceManuOrderRequest; import com.glxp.api.req.trace.TraceOrderDetailRequest; @@ -21,8 +23,10 @@ import com.glxp.api.res.trace.TraceManuOrderResponse; import com.glxp.api.res.trace.TraceOrderResponse; import com.glxp.api.res.trace.TraceRecordResponse; import com.glxp.api.res.trace.TraceSearchReponse; +import com.glxp.api.service.sup.UserCompanyService; import com.glxp.api.service.trace.TraceManuOrderService; import com.glxp.api.service.trace.TraceOrderService; +import com.glxp.api.service.trace.TraceProductDetailService; import com.glxp.api.service.trace.TraceRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -50,6 +54,8 @@ public class TraceRecordController extends BaseController { TraceOrderService traceOrderService; @Resource TraceManuOrderService traceManuOrderService; + @Resource + TraceProductDetailService traceProductDetailService; // 查询记录搜索 @@ -67,6 +73,9 @@ public class TraceRecordController extends BaseController { } + @Resource + UserCompanyService userCompanyService; + @ApiOperation(value = "追溯查询记录结果", response = TraceRecordResponse.class) @AuthRuleAnnotation("udi/trace/record/result") @GetMapping("udi/trace/record/result") @@ -74,16 +83,31 @@ public class TraceRecordController extends BaseController { if (StrUtil.isNotEmpty(traceRecordRequest.getRecordCode())) { TraceRecordLogEntity traceRecordLogEntity = traceRecordService.getOne(new QueryWrapper().eq("recordCode", traceRecordRequest.getRecordCode())); + if (traceRecordLogEntity == null) { return ResultVOUtils.error(500, "查询记录不存在!"); } + + TraceProductDetailEntity traceProductDetailEntity = traceProductDetailService.getById(traceRecordLogEntity.getTraceProductIdFk()); + UserCompanyEntity userCompanyEntity = null; + if (StrUtil.isNotEmpty(traceProductDetailEntity.getCompanyIdFk())) { + userCompanyEntity = userCompanyService.getById(traceProductDetailEntity.getCompanyIdFk()); + } TraceOrderDetailRequest traceOrderDetailRequest = new TraceOrderDetailRequest(); traceOrderDetailRequest.setTraceProductIdFk(traceRecordLogEntity.getTraceProductIdFk()); List traceOrderEntities = traceOrderService.filterJoin(traceOrderDetailRequest); - + if (CollUtil.isNotEmpty(traceOrderEntities)) { + for (TraceOrderResponse traceOrderResponse : traceOrderEntities) { + if (userCompanyEntity != null && userCompanyEntity.getCreditNum().equals(traceOrderResponse.getCompanyCertNum())) { + traceOrderResponse.setIsCurrent(true); + } + } + } TraceManuOrderRequest traceManuOrderRequest = new TraceManuOrderRequest(); traceManuOrderRequest.setTraceProductIdFk(traceRecordLogEntity.getTraceProductIdFk()); List traceManuOrderEntities = traceManuOrderService.filterTraces(traceManuOrderRequest); + + TraceSearchReponse traceSearchReponse = new TraceSearchReponse(); traceSearchReponse.setTraceOrderEntities(traceOrderEntities); traceSearchReponse.setTraceManuOrderEntities(traceManuOrderEntities); 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 4ed8e79..fcd1947 100644 --- a/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java +++ b/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java @@ -69,7 +69,8 @@ public class UdiTraceController extends BaseController { @Resource TraceManuCodeRelService traceManuCodeRelService; @Resource - TraceRecordService traceRecordService; @Resource + TraceRecordService traceRecordService; + @Resource UdiTraceService udiTraceService; @Resource @@ -141,7 +142,7 @@ public class UdiTraceController extends BaseController { //5.创建查询详情记录,若存在相同查询记录则直接获取 - traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 1, 1, basicUdiRelResponse, udiEntity); + traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 1, 1, basicUdiRelResponse, udiEntity, null); traceRecordLogEntity.setTraceProductIdFk(traceProductDetailEntity.getId()); traceRecordService.updateById(traceRecordLogEntity); for (UserCompanyResponse userCompanyResponse : userCompanyResponses) { @@ -187,7 +188,7 @@ public class UdiTraceController extends BaseController { traceRecordLogEntity = udiTraceService.createRecordLog(userId, traceRecordRequest.getFromType(), traceRecordRequest.getTraceType()); //5.创建查询详情记录,若存在相同查询记录则直接获取 - traceProductDetailEntity = udiTraceService.createTracerProductByBatchNo(traceRecordRequest, 1, 2, basicUdiRelResponse); + traceProductDetailEntity = udiTraceService.createTracerProductByBatchNo(traceRecordRequest, 1, 2, basicUdiRelResponse, null); traceRecordLogEntity.setTraceProductIdFk(traceProductDetailEntity.getId()); traceRecordService.updateById(traceRecordLogEntity); for (UserCompanyResponse userCompanyResponse : userCompanyResponses) { @@ -248,7 +249,7 @@ public class UdiTraceController extends BaseController { //5.创建查询详情记录,若存在相同查询记录则直接获取 - traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 2, 1, basicUdiRelResponse, udiEntity); + traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 2, 1, basicUdiRelResponse, udiEntity, traceRecordRequest.getCompanyId() + ""); traceRecordLogEntity.setTraceProductIdFk(traceProductDetailEntity.getId()); traceRecordService.updateById(traceRecordLogEntity); udiTraceService.createCheckTraceTask(traceProductDetailEntity, userCompanyEntity.getId()); @@ -286,7 +287,7 @@ public class UdiTraceController extends BaseController { traceRecordLogEntity = udiTraceService.createRecordLog(userId, traceRecordRequest.getFromType(), traceRecordRequest.getTraceType()); //5.创建查询详情记录,若存在相同查询记录则直接获取 - traceProductDetailEntity = udiTraceService.createTracerProductByBatchNo(traceRecordRequest, 2, 2, basicUdiRelResponse); + traceProductDetailEntity = udiTraceService.createTracerProductByBatchNo(traceRecordRequest, 2, 2, basicUdiRelResponse, traceRecordRequest.getCompanyId() + ""); udiTraceService.createCheckTraceTask(traceProductDetailEntity, userCompanyEntity.getId()); } // List traceOrderEntities = traceOrderService.findByProductIdFk(traceRecordLogEntity.getTraceProductIdFk()); diff --git a/src/main/java/com/glxp/api/entity/trace/TraceProductDetailEntity.java b/src/main/java/com/glxp/api/entity/trace/TraceProductDetailEntity.java index 0f50d06..8f4e2ee 100644 --- a/src/main/java/com/glxp/api/entity/trace/TraceProductDetailEntity.java +++ b/src/main/java/com/glxp/api/entity/trace/TraceProductDetailEntity.java @@ -108,5 +108,11 @@ public class TraceProductDetailEntity implements Serializable { */ @TableField(value = "zczbhhzbapzbh") private String zczbhhzbapzbh; + + /** + * 企业信息ID外键 + */ + @TableField(value = "companyIdFk") + private String companyIdFk; private static final long serialVersionUID = 1L; } diff --git a/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java b/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java index fd8623f..fad5cf7 100644 --- a/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java +++ b/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java @@ -179,6 +179,9 @@ public class TraceOrderResponse { private Integer invCount; + private Boolean isCurrent; + + //获取往来信息 @ApiModelProperty(value = "往来单位信息") private String fromToCorp; diff --git a/src/main/java/com/glxp/api/service/trace/UdiTraceService.java b/src/main/java/com/glxp/api/service/trace/UdiTraceService.java index 30fc1e2..5707f6e 100644 --- a/src/main/java/com/glxp/api/service/trace/UdiTraceService.java +++ b/src/main/java/com/glxp/api/service/trace/UdiTraceService.java @@ -64,7 +64,7 @@ public class UdiTraceService { } //创建追溯产品详情 - public TraceProductDetailEntity createTracerProductByUdiCode(String udiCode, Integer traceSource, Integer traceType, BasicUdiRelResponse basicUdiRelResponse, UdiEntity udiEntity) { + public TraceProductDetailEntity createTracerProductByUdiCode(String udiCode, Integer traceSource, Integer traceType, BasicUdiRelResponse basicUdiRelResponse, UdiEntity udiEntity, String companyIdFk) { TraceProductDetailEntity traceProductDetailEntity = null; traceProductDetailEntity = traceProductDetailService.findUniqueByCode(1, udiCode); if (traceProductDetailEntity == null) { @@ -86,6 +86,7 @@ public class UdiTraceService { traceProductDetailEntity.setExpireDate(udiEntity.getExpireDate()); traceProductDetailEntity.setSerialNo(udiEntity.getSerialNo()); traceProductDetailEntity.setZczbhhzbapzbh(basicUdiRelResponse.getZczbhhzbapzbh()); + traceProductDetailEntity.setCompanyIdFk(companyIdFk); traceProductDetailEntity.setStatus(1); traceProductDetailService.save(traceProductDetailEntity); return traceProductDetailEntity; @@ -95,7 +96,7 @@ public class UdiTraceService { //创建追溯产品详情 - public TraceProductDetailEntity createTracerProductByBatchNo(TraceRecordRequest traceRecordRequest, Integer traceSource, Integer traceType, BasicUdiRelResponse basicUdiRelResponse) { + public TraceProductDetailEntity createTracerProductByBatchNo(TraceRecordRequest traceRecordRequest, Integer traceSource, Integer traceType, BasicUdiRelResponse basicUdiRelResponse, String companyIdFk) { TraceProductDetailEntity traceProductDetailEntity = null; traceProductDetailEntity = traceProductDetailService.findUniqueByData(1, traceRecordRequest.getYlqxzcrbarmc(), @@ -114,6 +115,7 @@ public class UdiTraceService { traceProductDetailEntity.setGgxh(basicUdiRelResponse.getGgxh()); traceProductDetailEntity.setNameCode(basicUdiRelResponse.getNameCode()); traceProductDetailEntity.setBatchNo(traceRecordRequest.getBatchNo()); + traceProductDetailEntity.setCompanyIdFk(companyIdFk); traceProductDetailEntity.setStatus(1); traceProductDetailService.save(traceProductDetailEntity); } diff --git a/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml b/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml index b2f4d11..4948405 100644 --- a/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml +++ b/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml @@ -51,6 +51,7 @@ trace_product_record.zczbhhzbapzbh, trace_product_record.traceSource, trace_order.*, + uc.creditNum companyCertNum, uc.companyName FROM trace_order left join trace_product_record diff --git a/src/main/resources/schemas/schema_v2.1.sql b/src/main/resources/schemas/schema_v2.1.sql index 35ec4da..ce35faf 100644 --- a/src/main/resources/schemas/schema_v2.1.sql +++ b/src/main/resources/schemas/schema_v2.1.sql @@ -14,6 +14,9 @@ CALL Pro_Temp_ColumnWork('trace_order', 'recordCode', 'varchar(255)', 1); CALL Pro_Temp_ColumnWork('trace_order', 'count', 'int', 1); CALL Pro_Temp_ColumnWork('trace_order', 'invCount', 'int', 1); +CALL Pro_Temp_ColumnWork('trace_product_record', 'companyIdFk', 'varchar(255)', 1); + +