From 0c5d88c1dbef4a49d188249e24209d3e46519a2e Mon Sep 17 00:00:00 2001 From: qiuyt Date: Thu, 12 Dec 2024 16:29:47 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=89=AB=E7=A0=81=E8=A1=A5=E9=BD=90?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E7=9A=84=E6=89=B9=E6=AC=A1=E5=8F=B7=20?= =?UTF-8?q?=E7=AD=89=E4=BF=A1=E6=81=AF=202=E3=80=81=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E6=89=AB=E7=A0=81=E8=AF=A6=E6=83=85=E5=87=BA?= =?UTF-8?q?=E4=B8=8D=E6=9D=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/glxp/api/entity/auth/AuthCompany.java | 4 +- .../AlihealthYljgCodedetailResponse.java | 7 +- .../service/collect/RelCodeBatchService.java | 15 ++- .../service/inout/impl/IoCodeTempService.java | 102 ++++++++++++++++-- src/main/resources/schemas/schema_v2.4.sql | 4 + 5 files changed, 115 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/glxp/api/entity/auth/AuthCompany.java b/src/main/java/com/glxp/api/entity/auth/AuthCompany.java index 85bddc71..22356fee 100644 --- a/src/main/java/com/glxp/api/entity/auth/AuthCompany.java +++ b/src/main/java/com/glxp/api/entity/auth/AuthCompany.java @@ -35,4 +35,6 @@ public class AuthCompany { @TableField(value = "appSecret") private String appSecret; -} \ No newline at end of file + @TableField(value = "refEntId") + private String refEntId; +} diff --git a/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgCodedetailResponse.java b/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgCodedetailResponse.java index 83b4cc8a..c1b54fc0 100644 --- a/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgCodedetailResponse.java +++ b/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgCodedetailResponse.java @@ -40,7 +40,7 @@ public class AlihealthYljgCodedetailResponse extends AlihealthKytCommonParameter public void disposeResult(JSONObject jsonObjectResult) { JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("models"); if (!Objects.isNull(jsonObjectModel)) { - this.code_full_info_dto = jsonObjectResult.getJSONArray("code_full_info_dto"); + this.code_full_info_dto = jsonObjectModel.getJSONArray("code_full_info_dto"); // this.setTotal_num(jsonObjectModel.getInt("total_num")); // this.setBill_up_out_detail_do(jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do")); @@ -56,9 +56,9 @@ public class AlihealthYljgCodedetailResponse extends AlihealthKytCommonParameter relCodeBatch.setProductCode(FilterUdiUtils.getUdi(jsonObject.getStr("code")).getUdi()); // relCodeBatch.setSubTypeNo(); // relCodeBatch.setCascadeRatio(); - relCodeBatch.setPackageSpec(jsonObject.getStr("pkg_spec_crit")); + relCodeBatch.setPackageSpec(jsonObject.getJSONObject("drug_ent_base_d_t_o").getStr("pkg_spec_crit")); // relCodeBatch.setComment(); - List jsonArray = (List) jsonObject.getJSONObject("code_produce_info_d_t_o").getJSONArray("produce_info_list"); + List jsonArray = (List) jsonObject.getJSONObject("code_produce_info_d_t_o").getJSONObject("produce_info_list").getJSONArray("produce_info_dto"); JSONObject produceInfo =jsonArray.get(0); relCodeBatch.setBatchNo(produceInfo.getStr("batch_no")); relCodeBatch.setMadeDate(produceInfo.getStr("produce_date_str")); @@ -75,6 +75,7 @@ public class AlihealthYljgCodedetailResponse extends AlihealthKytCommonParameter relCodeBatch.setParentCode(null); relCodeBatch.setErpId(customerId); relCodeBatch.setCurCode(jsonObject.getStr("code")); + relCodeBatch.setParentCode(jsonObject.getStr("code")); // if(jsonObject.getJSONObject("p_user_ent_d_t_o").equals("1")){ // // }else if(jsonObject.getJSONObject("p_user_ent_d_t_o").equals("2")){ diff --git a/src/main/java/com/glxp/api/service/collect/RelCodeBatchService.java b/src/main/java/com/glxp/api/service/collect/RelCodeBatchService.java index d497e285..cded78d6 100644 --- a/src/main/java/com/glxp/api/service/collect/RelCodeBatchService.java +++ b/src/main/java/com/glxp/api/service/collect/RelCodeBatchService.java @@ -14,9 +14,11 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.dao.auth.AuthCompanyMapper; import com.glxp.api.dao.collect.RelCodeBatchMapper; import com.glxp.api.dao.inout.IoCodeTempDao; import com.glxp.api.entity.auth.AuthAdmin; +import com.glxp.api.entity.auth.AuthCompany; import com.glxp.api.entity.auth.CustomerInfoEntity; import com.glxp.api.entity.basic.ProductInfoEntity; import com.glxp.api.entity.basic.UdiEntity; @@ -25,8 +27,11 @@ import com.glxp.api.entity.collect.RelCodeBatch; import com.glxp.api.entity.collect.RelCodeDetail; import com.glxp.api.entity.inout.IoCodeTempEntity; import com.glxp.api.entity.sync.SyncDataSetEntity; +import com.glxp.api.entity.system.CompanyEntity; import com.glxp.api.exception.JsonException; +import com.glxp.api.req.alihealth.AlihealthYljgCodedetailReqeust; import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust; +import com.glxp.api.req.alihealth.local.AlihealthYljgLocaCodedetailReqeust; import com.glxp.api.req.collect.RelCodeBatchRequest; import com.glxp.api.req.collect.RelCodeDetailRequest; import com.glxp.api.res.alihealth.AlihealthKytSinglerelationResponse; @@ -37,8 +42,10 @@ import com.glxp.api.service.auth.CustomerService; import com.glxp.api.service.basic.ProductInfoService; import com.glxp.api.service.basic.UdiProductService; import com.glxp.api.service.sync.SyncDataSetService; +import com.glxp.api.service.system.CompanyService; import com.glxp.api.util.HttpClient; import com.glxp.api.util.alihealth.AlihealthUtils; +import com.glxp.api.util.alihealth.AlihealthYljgUtils; import com.glxp.api.util.udi.FilterUdiUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; @@ -375,10 +382,10 @@ public class RelCodeBatchService extends ServiceImpl { List ioCodeTempEntities = ioCodeTempDao.selectList(new LambdaQueryWrapper().eq(IoCodeTempEntity::getCode, parentCode)); if (CollUtil.isNotEmpty(ioCodeTempEntities)) { 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 3509610e..49181fef 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 @@ -12,20 +12,23 @@ import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.constant.Constant; import com.glxp.api.constant.ConstantStatus; import com.glxp.api.constant.ConstantType; +import com.glxp.api.dao.auth.AuthCompanyMapper; import com.glxp.api.dao.inout.IoCodeDao; import com.glxp.api.dao.inout.IoCodeTempDao; +import com.glxp.api.dao.inout.IoOrderDetailBizDao; import com.glxp.api.entity.auth.AuthAdmin; +import com.glxp.api.entity.auth.AuthCompany; import com.glxp.api.entity.auth.InvWarehouseEntity; import com.glxp.api.entity.basic.BasicBussinessTypeEntity; import com.glxp.api.entity.basic.UdiEntity; import com.glxp.api.entity.basic.UdiProductEntity; +import com.glxp.api.entity.collect.RelCodeBatch; import com.glxp.api.entity.collect.RelCodeDetail; -import com.glxp.api.entity.inout.IoCodeEntity; -import com.glxp.api.entity.inout.IoCodeLostEntity; -import com.glxp.api.entity.inout.IoCodeTempEntity; -import com.glxp.api.entity.inout.IoOrderEntity; +import com.glxp.api.entity.inout.*; import com.glxp.api.entity.purchase.SupCertEntity; import com.glxp.api.entity.purchase.SupProductEntity; +import com.glxp.api.req.alihealth.AlihealthYljgCodedetailReqeust; +import com.glxp.api.req.alihealth.local.AlihealthYljgLocaCodedetailReqeust; import com.glxp.api.req.basic.CompanyProductRelevanceRequest; import com.glxp.api.req.inout.AddOrderRequest; import com.glxp.api.req.inout.FilterCodeRequest; @@ -46,23 +49,23 @@ import com.glxp.api.service.purchase.SupCertService; import com.glxp.api.service.purchase.SupProductService; import com.glxp.api.service.system.SystemParamConfigService; import com.glxp.api.util.*; +import com.glxp.api.util.alihealth.AlihealthYljgUtils; import com.glxp.api.util.page.PageQuery; import com.glxp.api.util.page.TableDataInfo; import com.glxp.api.util.udi.FilterUdiUtils; import com.glxp.api.util.udi.UdiCalCountUtil; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Locale; +import java.util.*; @Service @Transactional(rollbackFor = Exception.class) +@Slf4j public class IoCodeTempService { @Resource @@ -242,7 +245,12 @@ public class IoCodeTempService { UdiRlSupService udiRlSupService; @Resource InvProductServiceNew invProductDetailService; - + @Resource + AlihealthYljgUtils alihealthYljgUtils; + @Resource + AuthCompanyMapper authCompanyMapper; + @Resource + IoOrderDetailBizDao ioOrderDetailBizDao; public BaseResponse addDrugOrderWeb(AddOrderRequest addOrderRequest) { @@ -381,7 +389,57 @@ public class IoCodeTempService { 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 = ""; @@ -549,6 +607,8 @@ public class IoCodeTempService { orderEntity.setBusType(bussinessTypeEntity.getBusType()); orderEntity.setProductType(2); orderService.insertOrder(orderEntity); + }else { + orderEntity.setProductType(2); } if (addOrderRequest.getOrderType() == ConstantStatus.ORDER_TYPE_NORMAL && bussinessTypeEntity.isCheckEnable() && bussinessTypeEntity.getCheckWebNew() != 0) { boolean isBillExit = orderDetailBizService.isExit(orderEntity.getBillNo()); @@ -622,6 +682,30 @@ public class IoCodeTempService { relCodeBatchService.threadUpdateIoCodeTempEntity(code); } } + RelCodeBatch relCodeBatchOne = relCodeBatchService.getOne(new QueryWrapper().eq("curCode", code) + .last("limit 1") + ); + if(relCodeBatchOne!=null){ + genDetaiEntity.setBatchNo(relCodeBatchOne.getBatchNo()); + genDetaiEntity.setProduceDate(relCodeBatchOne.getMadeDate()); + genDetaiEntity.setExpireDate(relCodeBatchOne.getValidateDate()); + + IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity(); + ioOrderDetailBizEntity.setBatchNo(relCodeBatchOne.getBatchNo()); + if(relCodeBatchOne.getMadeDate().length() > 10){ + ioOrderDetailBizEntity.setProductDate( relCodeBatchOne.getMadeDate().replace("-","").substring(2,8)); + + } + if(relCodeBatchOne.getValidateDate().length() > 10){ + ioOrderDetailBizEntity.setExpireDate(relCodeBatchOne.getValidateDate().replace("-","").substring(2,8)); + + } + + ioOrderDetailBizDao.update(ioOrderDetailBizEntity, + new QueryWrapper().eq("orderIdFk",orderEntity.getBillNo()) + ); +// genDetaiEntity.setExpireDate(relCodeBatchOne.getValidateDate()); + } addCodeResult.setOrderId(orderId); transInoutService.genOrderDetailCode(orderEntity, genDetaiEntity); return ResultVOUtils.success(addCodeResult); diff --git a/src/main/resources/schemas/schema_v2.4.sql b/src/main/resources/schemas/schema_v2.4.sql index 2b85b9c5..1ec76c61 100644 --- a/src/main/resources/schemas/schema_v2.4.sql +++ b/src/main/resources/schemas/schema_v2.4.sql @@ -1244,3 +1244,7 @@ CREATE TABLE IF NOT EXISTS `auth_ali_user` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci; CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'checkWebNewType', 'tinyint', 1); + +CALL Pro_Temp_ColumnWork('auth_company', 'refEntId', + ' varchar(255) DEFAULT NULL COMMENT ''接口调用企业的唯一标识''', + 1);