From b3da30fdc497e162c901e04d652e19fb184c905a Mon Sep 17 00:00:00 2001 From: yewj Date: Fri, 13 Dec 2024 17:42:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/inout/IoCheckInoutService.java | 2 +- .../service/inout/impl/IoCodeTempService.java | 169 ++++++++---------- 2 files changed, 78 insertions(+), 93 deletions(-) diff --git a/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java b/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java index f424050b..bc9d5753 100644 --- a/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java +++ b/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java @@ -334,7 +334,7 @@ public class IoCheckInoutService { if (vailBatchNo) { bizEntity = orderDetailBizService.findByUnique(codeEntity.getOrderId(), codeEntity.getRelId(), codeEntity.getBatchNo()); } else { - bizEntity = orderDetailBizService.findByUnique(codeEntity.getOrderId(), codeEntity.getRelId(), codeEntity.getBatchNo(), codeEntity.getProduceDate(), codeEntity.getExpireDate()); + bizEntity = orderDetailBizService.findByUnique(codeEntity.getOrderId(), codeEntity.getRelId(), codeEntity.getBatchNo(), null, null); } if (bizEntity == null) { return "非此单产品!"; diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoCodeTempService.java b/src/main/java/com/glxp/api/service/inout/impl/IoCodeTempService.java index 1c1c3240..34bbd241 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoCodeTempService.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoCodeTempService.java @@ -1,6 +1,7 @@ package com.glxp.api.service.inout.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -279,7 +280,7 @@ public class IoCodeTempService { if (StrUtil.isNotEmpty(addOrderRequest.getSerialNo())) { udiEntity.setSerialNo(addOrderRequest.getSerialNo()); } - RelCodeDetailResponse codeRelEntity = null; + RelCodeDetailResponse relCodeDetailResponse = relCodeDetailService.findByCode(code); if (StrUtil.isEmpty(udiEntity.getBatchNo())) { IoCodeLostEntity codeLostEntity = codeLostService.findByCode(code); if (codeLostEntity != null) { @@ -287,14 +288,51 @@ public class IoCodeTempService { udiEntity.setProduceDate(codeLostEntity.getProduceDate()); udiEntity.setExpireDate(codeLostEntity.getExpireDate()); } else { - codeRelEntity = relCodeDetailService.findByCode(code); - if (codeRelEntity != null) { - udiEntity.setBatchNo(codeRelEntity.getBatchNo()); - udiEntity.setProduceDate(DateUtil.formatDate(codeRelEntity.getMadeDate(), "yyMMdd")); - udiEntity.setExpireDate(DateUtil.formatDate(codeRelEntity.getValidateDate(), "yyMMdd")); + if (relCodeDetailResponse != null) { + udiEntity.setBatchNo(relCodeDetailResponse.getBatchNo()); + udiEntity.setProduceDate(DateUtil.formatDate(relCodeDetailResponse.getMadeDate(), "yyMMdd")); + udiEntity.setExpireDate(DateUtil.formatDate(relCodeDetailResponse.getValidateDate(), "yyMMdd")); + } else { + // 还是为空就调用查码明细的结构 + AuthCompany authCompany = authCompanyMapper.selectOne( + new QueryWrapper().last("limit 1") + ); + if (authCompany != null) { + AlihealthYljgLocaCodedetailReqeust alihealthYljgLocaCodedetailReqeust = new AlihealthYljgLocaCodedetailReqeust(); + alihealthYljgLocaCodedetailReqeust.setAppSecret(authCompany.getAppSecret()); + AlihealthYljgCodedetailReqeust alihealthYljgCodedetailReqeust = new AlihealthYljgCodedetailReqeust(); + alihealthYljgCodedetailReqeust.setRef_ent_id(authCompany.getRefEntId()); + alihealthYljgCodedetailReqeust.setCodes(code); + alihealthYljgCodedetailReqeust.setApp_key(authCompany.getAppId()); + alihealthYljgLocaCodedetailReqeust.setAlihealthYljgCodedetailReqeust(alihealthYljgCodedetailReqeust); + BaseResponse> response = alihealthYljgUtils.codedetail(alihealthYljgLocaCodedetailReqeust); + if (response.getCode() == 20000) { + List relCodeBatchList = response.getData(); + if (relCodeBatchList != null && relCodeBatchList.size() > 0) { + RelCodeBatch relCodeBatch = relCodeBatchList.get(0); + IoCodeLostEntity connLostEntity = new IoCodeLostEntity(); + connLostEntity.setId(IdUtil.getSnowflakeNextId()); + connLostEntity.setCode(relCodeBatch.getCurCode()); + connLostEntity.setBatchNo(relCodeBatch.getBatchNo()); + connLostEntity.setProduceDate(relCodeBatch.getMadeDate()); + connLostEntity.setExpireDate(relCodeBatch.getValidateDate()); + connLostEntity.setBatchNo(relCodeBatch.getBatchNo()); + codeLostService.saveOrUpdate(connLostEntity); + udiEntity.setBatchNo(connLostEntity.getBatchNo()); + udiEntity.setProduceDate(connLostEntity.getProduceDate()); + udiEntity.setExpireDate(connLostEntity.getExpireDate()); + } + } else { + log.error("拉取阿里码明细访问失败===" + response.getMessage()); + } + } + + } } } + + //批次号校验 //判断此产品是否开启允许无批次号 UdiProductEntity udiInfoEntity = udiProductService.findByNameCode(udiEntity.getUdi()); @@ -384,62 +422,10 @@ public class IoCodeTempService { } if (IntUtil.value(udiRelevanceResponse.getPackLevel()) == 0) { - RelCodeDetailResponse relCodeDetailResponse = relCodeDetailService.findByCode(code); if (relCodeDetailResponse == null) { return ResultVOUtils.error(500, "请先上传关联关系!"); } } - try { - // 调用阿里获取码信息 - List ioCodeTempEntities = ioCodeTempDao.selectList(new LambdaQueryWrapper().eq(IoCodeTempEntity::getCode, code)); - IoCodeTempEntity codeTempEntity =new IoCodeTempEntity(); - if (CollUtil.isNotEmpty(ioCodeTempEntities)) { - codeTempEntity = ioCodeTempEntities.get(0); - - } - List navList = relCodeBatchService.list(new LambdaQueryWrapper() - .eq(RelCodeBatch::getCurCode, code)); - // 还是为空就调用查码明细的结构 - if (navList == null || navList.size() == 0) { - AuthCompany authCompany = authCompanyMapper.selectOne( - new QueryWrapper().last("limit 1") - ); - if (authCompany != null) { - AlihealthYljgLocaCodedetailReqeust alihealthYljgLocaCodedetailReqeust = new AlihealthYljgLocaCodedetailReqeust(); - alihealthYljgLocaCodedetailReqeust.setErpId(codeTempEntity.getSupId()); - alihealthYljgLocaCodedetailReqeust.setAppSecret(authCompany.getAppSecret()); - AlihealthYljgCodedetailReqeust alihealthYljgCodedetailReqeust = new AlihealthYljgCodedetailReqeust(); - alihealthYljgCodedetailReqeust.setRef_ent_id(authCompany.getRefEntId()); - alihealthYljgCodedetailReqeust.setCodes(code); - alihealthYljgCodedetailReqeust.setApp_key(authCompany.getAppId()); - alihealthYljgLocaCodedetailReqeust.setAlihealthYljgCodedetailReqeust(alihealthYljgCodedetailReqeust); - BaseResponse> response = alihealthYljgUtils.codedetail(alihealthYljgLocaCodedetailReqeust); - if (response.getCode() == 20000) { - List relCodeBatchList = response.getData(); - if (relCodeBatchList != null && relCodeBatchList.size() > 0) { - for (RelCodeBatch relCodeBatch : relCodeBatchList) { - RelCodeBatch relCodeBatchOne = relCodeBatchService.getOne(new QueryWrapper().eq("productCode", relCodeBatch.getProductCode()) - .last("limit 1") - ); - if (Objects.isNull(relCodeBatchOne)) { - relCodeBatch.setCreateUser(codeTempEntity.getSupId()); - relCodeBatch.setCreateTime(new Date()); - relCodeBatchService.save(relCodeBatch); - - } else { - relCodeBatchService.update(relCodeBatch, new QueryWrapper().eq("productCode", relCodeBatch.getProductCode())); - } - } - } - } else { - log.error("拉取阿里码明细访问失败===" + response.getMessage()); - } - } - } - }catch (Exception e){ - log.error("拉取阿里码明细访问失败===" + e.getMessage()); - - } //先生成扫码单据 IoOrderEntity orderEntity = orderService.findByBillNo(orderId); String inBatch = ""; @@ -523,9 +509,9 @@ public class IoCodeTempService { codeEnttity.setSerialNo(udiEntity.getSerialNo()); codeEnttity.setDeptCode(invWarehouseEntity.getParentId()); codeEnttity.setInvCode(addOrderRequest.getInvCode()); - if (codeRelEntity != null) { - codeEnttity.setParentCode(codeRelEntity.getParentCode()); - RelCodeDetail relCodeDetail = relCodeDetailService.getOneByCode(codeRelEntity.getParentCode()); + if (relCodeDetailResponse != null) { + codeEnttity.setParentCode(relCodeDetailResponse.getParentCode()); + RelCodeDetail relCodeDetail = relCodeDetailService.getOneByCode(relCodeDetailResponse.getParentCode()); if (relCodeDetail != null) { codeEnttity.setGrantPaCode(relCodeDetail.getParentCode()); } @@ -594,7 +580,8 @@ public class IoCodeTempService { orderEntity.setFromType(ConstantStatus.FROM_WEBNEW); orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT); - AuthAdmin authAdmin = customerService.getUserBean();; + AuthAdmin authAdmin = customerService.getUserBean(); + ; orderEntity.setCreateUser(authAdmin.getId() + ""); orderEntity.setCreateTime(new Date()); orderEntity.setUpdateUser(authAdmin.getId() + ""); @@ -607,7 +594,7 @@ public class IoCodeTempService { orderEntity.setBusType(bussinessTypeEntity.getBusType()); orderEntity.setProductType(2); orderService.insertOrder(orderEntity); - }else { + } else { orderEntity.setProductType(2); } if (addOrderRequest.getOrderType() == ConstantStatus.ORDER_TYPE_NORMAL && bussinessTypeEntity.isCheckEnable() && bussinessTypeEntity.getCheckWebNew() != 0) { @@ -682,36 +669,34 @@ public class IoCodeTempService { relCodeBatchService.threadUpdateIoCodeTempEntity(code); } } - RelCodeBatch relCodeBatchOne = relCodeBatchService.getOne(new QueryWrapper().eq("curCode", code) - .last("limit 1") - ); - if(relCodeBatchOne!=null){ - String mabeDate = relCodeBatchOne.getMadeDate(); - String validateDate = relCodeBatchOne.getValidateDate(); - - - if(mabeDate.length() > 10){ - mabeDate =mabeDate.replace("-","").substring(2,8); - } - if(validateDate.length() > 10){ - validateDate = validateDate.replace("-","").substring(2,8); - - } - genDetaiEntity.setBatchNo(relCodeBatchOne.getBatchNo()); - genDetaiEntity.setProduceDate(mabeDate); - genDetaiEntity.setExpireDate(validateDate); - - IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity(); - ioOrderDetailBizEntity.setBatchNo(relCodeBatchOne.getBatchNo()); - ioOrderDetailBizEntity.setProductDate( mabeDate); - ioOrderDetailBizEntity.setExpireDate(validateDate); - - ioOrderDetailBizDao.update(ioOrderDetailBizEntity, - new QueryWrapper().eq("orderIdFk",orderEntity.getBillNo()) - ); -// genDetaiEntity.setExpireDate(relCodeBatchOne.getValidateDate()); - } +// if(relCodeBatchOne!=null){ +// String mabeDate = relCodeBatchOne.getMadeDate(); +// String validateDate = relCodeBatchOne.getValidateDate(); +// +// +// if(mabeDate.length() > 10){ +// mabeDate =mabeDate.replace("-","").substring(2,8); +// +// } +// if(validateDate.length() > 10){ +// validateDate = validateDate.replace("-","").substring(2,8); +// +// } +// genDetaiEntity.setBatchNo(relCodeBatchOne.getBatchNo()); +// genDetaiEntity.setProduceDate(mabeDate); +// genDetaiEntity.setExpireDate(validateDate); +// +// IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity(); +// ioOrderDetailBizEntity.setBatchNo(relCodeBatchOne.getBatchNo()); +// ioOrderDetailBizEntity.setProductDate( mabeDate); +// ioOrderDetailBizEntity.setExpireDate(validateDate); +// +// ioOrderDetailBizDao.update(ioOrderDetailBizEntity, +// new QueryWrapper().eq("orderIdFk",orderEntity.getBillNo()) +// ); +//// genDetaiEntity.setExpireDate(relCodeBatchOne.getValidateDate()); +// } addCodeResult.setOrderId(orderId); transInoutService.genOrderDetailCode(orderEntity, genDetaiEntity); return ResultVOUtils.success(addCodeResult);