diff --git a/src/main/java/com/glxp/api/controller/inout/IoCodeController.java b/src/main/java/com/glxp/api/controller/inout/IoCodeController.java index 8950bba2..fc8e2204 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoCodeController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoCodeController.java @@ -1,5 +1,6 @@ package com.glxp.api.controller.inout; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageInfo; @@ -7,13 +8,19 @@ import com.glxp.api.annotation.AuthRuleAnnotation; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.controller.BaseController; +import com.glxp.api.dao.inout.IoOrderDao; import com.glxp.api.entity.alihealth.YcFileCodeUploadVo; import com.glxp.api.entity.inout.IoCodeEntity; +import com.glxp.api.entity.inout.IoOrderEntity; import com.glxp.api.exception.JsonException; import com.glxp.api.req.inout.FilterCodeRequest; +import com.glxp.api.req.inout.FilterOrderDetailBizRequest; import com.glxp.api.req.inout.YcFileCodeUploadRequest; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.inout.IoCodeResponse; +import com.glxp.api.res.inout.IoOrderDetailBizResponse; +import com.glxp.api.service.inout.IoOrderDetailBizService; +import com.glxp.api.service.inout.IoOrderService; import com.glxp.api.service.inout.impl.IoCodeService; import com.glxp.api.util.Excel.ExcelHandler; import com.glxp.api.util.Excel.ExcelTemplateEnum; @@ -26,6 +33,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -37,6 +45,10 @@ public class IoCodeController extends BaseController { @Resource private IoCodeService ioCodeService; + @Resource + private IoOrderService ioOrderService; + @Resource + private IoOrderDetailBizService ioOrderDetailBizService; /** * 查询单据正式码表数据 @@ -112,12 +124,46 @@ public class IoCodeController extends BaseController { throw new JsonException("单据编号不能为空!"); } + //获取订单的详情 + IoOrderEntity ioOrderEntity = ioOrderService.findByBillNo(billNo); + if (ioOrderEntity == null) { + throw new JsonException("单据未找到!"); + } + + //获取biz表 + FilterOrderDetailBizRequest orderDetailBizRequest = new FilterOrderDetailBizRequest(); + orderDetailBizRequest.setOrderIdFk(billNo); + List ioOrderDetailBizResponses = ioOrderDetailBizService.filterList(orderDetailBizRequest); + if (CollUtil.isEmpty(ioOrderDetailBizResponses)) { + throw new JsonException("单据业务明细未找到!"); + } + + FilterCodeRequest filterCodeRequest = new FilterCodeRequest(); + List exportExcelList = new ArrayList<>(); + String ycBillNo = ioOrderEntity.getYcBillNo(); + filterCodeRequest.setYcBillNo(ycBillNo); + + //遍历biz获取codeList + for (int i = 0; i < ioOrderDetailBizResponses.size(); i++) { + IoOrderDetailBizResponse ioOrderDetailBizResponse = ioOrderDetailBizResponses.get(i); + + filterCodeRequest.setYcBizNo(ioOrderDetailBizResponse.getYcBizNo()); + filterCodeRequest.setRelId(String.valueOf(ioOrderDetailBizResponse.getBindRlFk())); + filterCodeRequest.setBatchNo(ioOrderDetailBizResponse.getBatchNo()); + + List list = ioCodeService.filterListexcelExport(filterCodeRequest); + + if (CollUtil.isNotEmpty(list)) { + exportExcelList.addAll(list); + } + } + try { - List list = ioCodeService.filterListexcelExport(ycFileCodeUploadRequest); - excelHandler.exportExcel(response, list, YcFileCodeUploadVo.class, "UDI_"+billNo+"追溯码导出", "追溯码"); + excelHandler.exportExcel(response, exportExcelList, YcFileCodeUploadVo.class, "UDI_"+billNo+"追溯码导出", "追溯码"); } catch (Exception e) { throw new RenException("导出失败"); } + } } diff --git a/src/main/java/com/glxp/api/dao/inout/IoCodeDao.java b/src/main/java/com/glxp/api/dao/inout/IoCodeDao.java index f4e14183..ac91e9b7 100644 --- a/src/main/java/com/glxp/api/dao/inout/IoCodeDao.java +++ b/src/main/java/com/glxp/api/dao/inout/IoCodeDao.java @@ -37,5 +37,5 @@ public interface IoCodeDao extends BaseMapperPlus findByCodeSumReCount(List codes); - List filterListexcelExport(YcFileCodeUploadRequest filterCodeRequest); + List filterListexcelExport(FilterCodeRequest filterCodeRequest); } diff --git a/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java b/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java index 75172646..81459869 100644 --- a/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java +++ b/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java @@ -17,7 +17,7 @@ public class YcFileCodeUploadVo { @ExcelProperty("交易明细编号") @ColumnWidth(30) - private String detailNo; + private String ycBizNo; @ExcelProperty("追溯码") @ColumnWidth(60) diff --git a/src/main/java/com/glxp/api/req/inout/FilterCodeRequest.java b/src/main/java/com/glxp/api/req/inout/FilterCodeRequest.java index 66bb75a7..e1ac25ca 100644 --- a/src/main/java/com/glxp/api/req/inout/FilterCodeRequest.java +++ b/src/main/java/com/glxp/api/req/inout/FilterCodeRequest.java @@ -72,5 +72,6 @@ public class FilterCodeRequest extends ListPageRequest { * 产品类型 */ - + private String ycBillNo; + private String ycBizNo; } diff --git a/src/main/java/com/glxp/api/res/inout/IoOrderDetailBizResponse.java b/src/main/java/com/glxp/api/res/inout/IoOrderDetailBizResponse.java index eb9d52e9..335161c2 100644 --- a/src/main/java/com/glxp/api/res/inout/IoOrderDetailBizResponse.java +++ b/src/main/java/com/glxp/api/res/inout/IoOrderDetailBizResponse.java @@ -1,5 +1,6 @@ package com.glxp.api.res.inout; +import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import java.math.BigDecimal; @@ -190,4 +191,11 @@ public class IoOrderDetailBizResponse { private String prepnUnit; + /** + * 单据产品类型 阳采交易明细单号 + */ + @TableField(value = "ycBizNo") + private String ycBizNo; + + } diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoCodeService.java b/src/main/java/com/glxp/api/service/inout/impl/IoCodeService.java index 5b0ebdae..e4764449 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoCodeService.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoCodeService.java @@ -172,7 +172,7 @@ public class IoCodeService extends ServiceImpl { return ioCodeDao.findByCodeSumReCount(codes); } - public List filterListexcelExport(YcFileCodeUploadRequest filterCodeRequest) { + public List filterListexcelExport(FilterCodeRequest filterCodeRequest) { return ioCodeDao.filterListexcelExport(filterCodeRequest); } } diff --git a/src/main/resources/mybatis/mapper/inout/IoCodeDao.xml b/src/main/resources/mybatis/mapper/inout/IoCodeDao.xml index 373d6673..c0e3e780 100644 --- a/src/main/resources/mybatis/mapper/inout/IoCodeDao.xml +++ b/src/main/resources/mybatis/mapper/inout/IoCodeDao.xml @@ -110,19 +110,15 @@