diff --git a/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java b/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java index 7970391a..68c758e1 100644 --- a/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java +++ b/src/main/java/com/glxp/api/controller/alihealth/AlihealthBusController.java @@ -13,6 +13,7 @@ import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.constant.BusinessType; import com.glxp.api.controller.BaseController; +import com.glxp.api.controller.inout.IoOrderReviewController; import com.glxp.api.dao.inout.IoCodeDao; import com.glxp.api.entity.alihealth.AliYljgBillDetail; import com.glxp.api.entity.alihealth.AliYljgSearchbill; @@ -26,6 +27,7 @@ import com.glxp.api.req.alihealth.AliYljgSearchbillReqeust; import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; import com.glxp.api.req.alihealth.AlihealthKytGetentinfoReqeust; import com.glxp.api.req.alihealth.AlihealthYljgUploadinoutbillReqeust; +import com.glxp.api.req.alihealth.local.AliBillsDisposeReqeust; import com.glxp.api.req.alihealth.local.AlihealthGetRelCodeReqeust; import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust; import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; @@ -39,6 +41,7 @@ import com.glxp.api.util.DateUtil; import com.glxp.api.util.alihealth.AlihealthUtils; import com.glxp.api.util.alihealth.AlihealthYljgUtils; import com.glxp.api.util.alihealth.PaginationUtil; +import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; @@ -100,14 +103,15 @@ public class AlihealthBusController extends BaseController { } } + @PostMapping("/spms/alihealth/thirdAliDrugList") @Log(title = "获取阿里药品码段信息列表包括查询国家库", businessType = BusinessType.OTHER) public BaseResponse> thirdAliDrugList(@RequestBody AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) { List thirdAliDrugsListGjk = null; - PageSimpleResponse pageSimpleResponse =new PageSimpleResponse(); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse(); // 本地查询和新增都先注释了 到时候加到这边来 YbDrug ybDrug = alihealthThirdAliDrugInsertReqeust.getYbDrug(); - if(alihealthThirdAliDrugInsertReqeust.isSelectCodeRelMark() && ybDrug!= null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())){ + if (alihealthThirdAliDrugInsertReqeust.isSelectCodeRelMark() && ybDrug != null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())) { // 用医保编码查询国家库药品信息 try { CodeRel codeReNew = new CodeRel(); @@ -117,13 +121,13 @@ public class AlihealthBusController extends BaseController { JSONObject.parseObject(response, new TypeReference>>() { }); - if(responseListAndAliDrug.getCode() == 20000){ + if (responseListAndAliDrug.getCode() == 20000) { thirdAliDrugsListGjk = responseListAndAliDrug.getData(); - if(thirdAliDrugsListGjk != null && thirdAliDrugsListGjk.size() >0){ + if (thirdAliDrugsListGjk != null && thirdAliDrugsListGjk.size() > 0) { pageSimpleResponse.setList(thirdAliDrugsListGjk); return ResultVOUtils.success(pageSimpleResponse); } - }else { + } else { pageSimpleResponse.setList(thirdAliDrugsListGjk); return ResultVOUtils.success(pageSimpleResponse); } @@ -132,39 +136,39 @@ public class AlihealthBusController extends BaseController { } - }else { + } else { // 查询国家库药品信息 并且要插入到多玛融合表 AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust(); ThirdAliDrugRequest thirdAliDrugRequest = new ThirdAliDrugRequest(); - BeanUtil.copyProperties(alihealthThirdAliDrugInsertReqeust,thirdAliDrugRequest); + BeanUtil.copyProperties(alihealthThirdAliDrugInsertReqeust, thirdAliDrugRequest); if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getPhysic_name())) { thirdAliDrugRequest.setCpmctymc(alihealthKytDrugrescodeReqeust.getPhysic_name()); } if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getApproval_licence_no())) { thirdAliDrugRequest.setApprovalNum(alihealthKytDrugrescodeReqeust.getApproval_licence_no()); } - try { - String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", BeanUtil.beanToMap(thirdAliDrugRequest)); - BaseResponse> udiDlDeviceResponse = - JSONObject.parseObject(response, new TypeReference>>() { - - }); - if (udiDlDeviceResponse != null - ) { - // 查询国家库是否有值 有值直接返回没值查询阿里接口 - thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList(); - if(thirdAliDrugsListGjk.size() == udiDlDeviceResponse.getData().getTotal()){ - thirdAliDrugsListGjk = PaginationUtil.getPage(thirdAliDrugsListGjk, alihealthThirdAliDrugInsertReqeust.getPage() - , alihealthThirdAliDrugInsertReqeust.getLimit()); - } - pageSimpleResponse.setList(thirdAliDrugsListGjk); - pageSimpleResponse.setTotal(Long.valueOf(udiDlDeviceResponse.getData().getTotal())); - } - } catch (Exception e) { - log.error("国家库===查询药品信息===出现错误===" + e.getMessage()); + try { + String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", BeanUtil.beanToMap(thirdAliDrugRequest)); + BaseResponse> udiDlDeviceResponse = + JSONObject.parseObject(response, new TypeReference>>() { + }); + if (udiDlDeviceResponse != null + ) { + // 查询国家库是否有值 有值直接返回没值查询阿里接口 + thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList(); + if (thirdAliDrugsListGjk.size() == udiDlDeviceResponse.getData().getTotal()) { + thirdAliDrugsListGjk = PaginationUtil.getPage(thirdAliDrugsListGjk, alihealthThirdAliDrugInsertReqeust.getPage() + , alihealthThirdAliDrugInsertReqeust.getLimit()); + } + pageSimpleResponse.setList(thirdAliDrugsListGjk); + pageSimpleResponse.setTotal(Long.valueOf(udiDlDeviceResponse.getData().getTotal())); } + } catch (Exception e) { + log.error("国家库===查询药品信息===出现错误===" + e.getMessage()); + + } return ResultVOUtils.success(pageSimpleResponse); } pageSimpleResponse.setList(thirdAliDrugsListGjk); @@ -234,6 +238,7 @@ public class AlihealthBusController extends BaseController { AliYljgBillDetail aliYljgBillDetail = alihealthBusService.aliYljgBillDetail(aliYljgSearchbillReqeust); return ResultVOUtils.success(aliYljgBillDetail); } + /** * 阿里手动拉取完成单大级码没有关联关系的接口 * @@ -241,6 +246,7 @@ public class AlihealthBusController extends BaseController { */ @Resource private RelCodeBatchService relCodeBatchService; + @PostMapping("/spms/alihealth/getAliCode") @Log(title = "阿里手动拉取完成单大级码没有关联关系的接口", businessType = BusinessType.OTHER) public BaseResponse getAliCode(@RequestBody AlihealthGetRelCodeReqeust alihealthGetRelCodeReqeust) { @@ -251,45 +257,18 @@ public class AlihealthBusController extends BaseController { return ResultVOUtils.success("成功"); } + @Resource - private IoCodeDao ioCodeDao; - @Resource - private AlihealthYljgUtils alihealthYljgUtils; - @PostMapping("/spms/alihealth/yljgUploadinoutbill") - @Log(title = "获取阿里药品的采购单码明细", businessType = BusinessType.OTHER) - public BaseResponse yljgUploadinoutbill(@RequestBody AlihealthGetRelCodeReqeust alihealthGetRelCodeReqeust) { - - List list = new ArrayList<>(); - list.add("ZS202502170071"); - list.add("ZS202502180035"); - list.add("ZS202502180034"); - list.add("ZS202502180024"); - list.add("ZS202502180013"); - list.add("ZS202502170148"); - list.add("ZS202502180040"); - list.add("ZS202501180311"); - for (String s : list) { - IoOrderEntity orderEntity = orderService.findByBillNo(s); - //1.上传入库单 - AlihealthYljgUploadinoutbillReqeust alihealthYljgUploadinoutbillReqeust = new AlihealthYljgUploadinoutbillReqeust(); - alihealthYljgUploadinoutbillReqeust.setBill_code(orderEntity.getBillNo()); - alihealthYljgUploadinoutbillReqeust.setBill_time(DateUtil.formatDateTime(orderEntity.getAuditTime())); - alihealthYljgUploadinoutbillReqeust.setBill_type(102); - // 先写死 到时候以阿里的为准 - alihealthYljgUploadinoutbillReqeust.setPhysic_type(3); - alihealthYljgUploadinoutbillReqeust.setClient_type("2"); - // 查询改单据传的码 - List ioCodeEntityList = ioCodeDao.selectList(new QueryWrapper().eq("orderId", orderEntity.getBillNo())); - if (ioCodeEntityList != null && ioCodeEntityList.size() > 0) { - List codeList = new ArrayList<>(); - for (IoCodeEntity ioCodeEntity : ioCodeEntityList) { - codeList.add(ioCodeEntity.getCode()); - } - Set set = new HashSet<>(codeList); - alihealthYljgUploadinoutbillReqeust.setTrace_codes(String.join(",", codeList)); - // 单据上传先注释了 - BaseResponse baseResponseUploadinoutbill = alihealthYljgUtils.yljgUploadinoutbill(alihealthYljgUploadinoutbillReqeust, orderEntity.getFromCorp()); - } + private IoOrderReviewController ioOrderReviewController; + @PostMapping("/spms/alihealth/aliBillsDispose") + @Log(title = "手动调用阿里单据上传和关联关系拉取", businessType = BusinessType.OTHER) + public BaseResponse aliBillsDispose(@RequestBody AliBillsDisposeReqeust aliBillsDisposeReqeust) { + + List ioOrderEntityList = aliBillsDisposeReqeust.getIoOrderEntityList(); + log.error("开始补救上传和拉取关联关系列表==="+ioOrderEntityList); + + for (IoOrderEntity ioOrderEntity : ioOrderEntityList) { + ioOrderReviewController.aliBillsDispose(ioOrderEntity); } diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java index 48ebcdb4..a88956a4 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoOrderReviewController.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; import com.glxp.api.annotation.AuthRuleAnnotation; @@ -16,10 +17,12 @@ import com.glxp.api.constant.Constant; import com.glxp.api.constant.ConstantStatus; import com.glxp.api.constant.ConstantType; import com.glxp.api.controller.BaseController; +import com.glxp.api.dao.basic.BasicProductsDao; import com.glxp.api.dao.inout.IoCodeDao; import com.glxp.api.dao.inout.IoCodeTempDao; import com.glxp.api.entity.auth.AuthAdmin; import com.glxp.api.entity.basic.BasicBussinessTypeEntity; +import com.glxp.api.entity.basic.BasicProductsEntity; import com.glxp.api.entity.basic.EntrustReceEntity; import com.glxp.api.entity.collect.RelCodeBatch; import com.glxp.api.entity.inout.*; @@ -49,7 +52,9 @@ import com.glxp.api.service.system.SystemParamConfigService; import com.glxp.api.util.*; import com.glxp.api.util.alihealth.AlihealthYljgUtils; import com.glxp.api.util.redis.RedisDelayedQueue; +import com.glxp.api.util.udi.FilterUdiUtils; import com.glxp.api.util.udi.UdiCalCountUtil; +import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.BindingResult; @@ -155,9 +160,12 @@ public class IoOrderReviewController extends BaseController { //todo 审核通过上传关联关系 BasicBussinessTypeEntity businessType = basicBussinessTypeService.findByAction(orderEntity.getAction()); log.error("单据审核进来了===businessType====" + businessType); - - if (businessType.getCorpType() == ConstantStatus.CORP_SP && businessType.getMainAction().equals(ConstantType.TYPE_PUT) && businessType.getProductType() == 2) { - aliBillsDispose(orderEntity); + String paramValue = systemParamConfigService.selectValueByParamKey("aliRelCodeDetail"); + if (businessType.getCorpType() == ConstantStatus.CORP_SP && businessType.getMainAction().equals(ConstantType.TYPE_PUT) && businessType.getProductType() == 2 + && StrUtil.isNotEmpty(paramValue) && paramValue.equals("1")) { + ThreadUtil.execAsync(() -> { + aliBillsDispose(orderEntity); + }); } } return baseResponse; @@ -469,44 +477,70 @@ public class IoOrderReviewController extends BaseController { private Integer relCodeDelaySeconds; @Resource private RedisDelayedQueue redisDelayedQueue; + @Resource + private BasicProductsDao basicProductsDao; // 异步处理阿里单据 public BaseResponse aliBillsDispose(IoOrderEntity orderEntity) { - ThreadUtil.execAsync(() -> { - //1.上传入库单 - AlihealthYljgUploadinoutbillReqeust alihealthYljgUploadinoutbillReqeust = new AlihealthYljgUploadinoutbillReqeust(); - alihealthYljgUploadinoutbillReqeust.setBill_code(orderEntity.getBillNo()); - alihealthYljgUploadinoutbillReqeust.setBill_time(DateUtil.formatDateTime(orderEntity.getAuditTime())); - alihealthYljgUploadinoutbillReqeust.setBill_type(102); - // 先写死 到时候以阿里的为准 - alihealthYljgUploadinoutbillReqeust.setPhysic_type(3); - alihealthYljgUploadinoutbillReqeust.setClient_type("2"); // 查询改单据传的码 List ioCodeEntityList = ioCodeDao.selectList(new QueryWrapper().eq("orderId", orderEntity.getBillNo())); if (ioCodeEntityList != null && ioCodeEntityList.size() > 0) { - List codeList = new ArrayList<>(); - for (IoCodeEntity ioCodeEntity : ioCodeEntityList) { - codeList.add(ioCodeEntity.getCode()); - } - Set set = new HashSet<>(codeList); - alihealthYljgUploadinoutbillReqeust.setTrace_codes(String.join(",", codeList)); - // 单据上传先注释了 - BaseResponse baseResponseUploadinoutbill = alihealthYljgUtils.yljgUploadinoutbill(alihealthYljgUploadinoutbillReqeust,orderEntity.getFromCorp()); - log.error("要查询阿里关联关系的码===" + set); - String erpId = orderEntity.getFromCorp(); - for (String code : set) { - relCodeBatchService.addRelCodeAli(code, orderEntity.getFromCorp()); - RelCodeBatch relCodeBatch = relCodeBatchService.getOne( - new QueryWrapper().eq("curCode", code) - ); - if (Objects.isNull(relCodeBatch)) { - redisDelayedQueue.addTaskToQueue(code + "&&&" + erpId, relCodeDelaySeconds, "rel_code_queue"); + int chunkSize = 250; + List> ioCodeEntityChunks = Lists.partition(ioCodeEntityList, chunkSize); + for (int i = 0; i < ioCodeEntityChunks.size(); i++) { + List ioCodeEntityChunk = ioCodeEntityChunks.get(i); + //1.上传入库单 + AlihealthYljgUploadinoutbillReqeust alihealthYljgUploadinoutbillReqeust = new AlihealthYljgUploadinoutbillReqeust(); + // 单据号处理 + if (ioCodeEntityChunks.size() < 2) { + alihealthYljgUploadinoutbillReqeust.setBill_code(orderEntity.getBillNo()); } else { - log.error("有关联关系了此码===" + code); + alihealthYljgUploadinoutbillReqeust.setBill_code(orderEntity.getBillNo() + "-" + (i + 1)); + } + alihealthYljgUploadinoutbillReqeust.setBill_time(DateUtil.formatDateTime(orderEntity.getAuditTime())); + alihealthYljgUploadinoutbillReqeust.setBill_type(102); + // 先写死 到时候以阿里的为准 + alihealthYljgUploadinoutbillReqeust.setPhysic_type(3); + alihealthYljgUploadinoutbillReqeust.setClient_type("2"); + List codeList = new ArrayList<>(); + for (IoCodeEntity ioCodeEntity : ioCodeEntityChunk) { + codeList.add(ioCodeEntity.getCode()); + } + Set set = new HashSet<>(codeList); + alihealthYljgUploadinoutbillReqeust.setTrace_codes(String.join(",", codeList)); + // 单据上传先注释了 + BaseResponse baseResponseUploadinoutbill = alihealthYljgUtils.yljgUploadinoutbill(alihealthYljgUploadinoutbillReqeust, orderEntity.getFromCorp()); + log.error("要查询阿里关联关系的码===" + set); + String erpId = orderEntity.getFromCorp(); + for (String code : set) { + // 只有大级码才调取关联关系 + BasicProductsEntity basicProductsEntity = basicProductsDao.selectOne( + new LambdaQueryWrapper() + .eq(BasicProductsEntity::getNameCode, FilterUdiUtils.getUdi(code).getUdi()) + .eq(BasicProductsEntity::getProductsType,2) + .last("limit 1") + ); + String packLevel = null; + if(basicProductsEntity != null){ + packLevel = basicProductsEntity.getPackLevel(); + } + if(StringUtils.isNotEmpty(packLevel) && (packLevel.equals("2") || packLevel.equals("3"))){ + relCodeBatchService.addRelCodeAli(code, orderEntity.getFromCorp()); + // 关联关系队列先不用了 直接用定时替代更可靠 +// RelCodeBatch relCodeBatch = relCodeBatchService.getOne( +// new QueryWrapper().eq("curCode", code) +// ); +// if (Objects.isNull(relCodeBatch)) { +// if(queueBo){ +// redisDelayedQueue.addTaskToQueue(code + "&&&" + erpId, relCodeDelaySeconds, "rel_code_queue"); +// } +// } else { +// log.error("有关联关系了此码===" + code); +// } + } } } } - }); return ResultVOUtils.success("更新成功"); } diff --git a/src/main/java/com/glxp/api/req/alihealth/local/AliBillsDisposeReqeust.java b/src/main/java/com/glxp/api/req/alihealth/local/AliBillsDisposeReqeust.java new file mode 100644 index 00000000..22f28365 --- /dev/null +++ b/src/main/java/com/glxp/api/req/alihealth/local/AliBillsDisposeReqeust.java @@ -0,0 +1,12 @@ +package com.glxp.api.req.alihealth.local; + +import com.glxp.api.entity.collect.IoCollectCodeBackup; +import com.glxp.api.entity.inout.IoOrderEntity; +import lombok.Data; + +import java.util.List; +@Data +public class AliBillsDisposeReqeust { + private List ioOrderEntityList; + +} diff --git a/src/main/java/com/glxp/api/task/AliRelCodeDetailTask.java b/src/main/java/com/glxp/api/task/AliRelCodeDetailTask.java index 6376ae19..4fd35f6a 100644 --- a/src/main/java/com/glxp/api/task/AliRelCodeDetailTask.java +++ b/src/main/java/com/glxp/api/task/AliRelCodeDetailTask.java @@ -1,99 +1,99 @@ -package com.glxp.api.task; - -import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.glxp.api.common.res.BaseResponse; -import com.glxp.api.dao.schedule.ScheduledDao; -import com.glxp.api.entity.collect.RelCodeBatch; -import com.glxp.api.entity.collect.RelCodeDetail; -import com.glxp.api.entity.system.ScheduledEntity; -import com.glxp.api.req.alihealth.AlihealthYljgSinglerelationReqeust; -import com.glxp.api.req.system.ScheduledRequest; -import com.glxp.api.res.alihealth.AlihealthYljgSinglerelationResponse; -import com.glxp.api.service.collect.RelCodeBatchService; -import com.glxp.api.service.collect.RelCodeDetailService; -import com.glxp.api.util.CacheUtils; -import com.glxp.api.util.DateUtil; -import com.glxp.api.util.RedisUtil; -import com.glxp.api.util.alihealth.AlihealthYljgUtils; -import com.glxp.api.util.redis.RedisDelayedQueue; -import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.SchedulingConfigurer; -import org.springframework.scheduling.config.ScheduledTaskRegistrar; -import org.springframework.scheduling.support.CronTrigger; -import org.springframework.stereotype.Component; -import redis.clients.jedis.resps.Tuple; - -import javax.annotation.Resource; -import java.util.*; - -@Component -@EnableScheduling -@Slf4j -public class AliRelCodeDetailTask implements SchedulingConfigurer { - - final Logger logger = LoggerFactory.getLogger(AsyncDiDlTask.class); - @Resource - AsyncCompanyDlHelper udiCompanyTask; - @Resource - RedisUtil redisUtil; - - @Resource - private ScheduledDao scheduledDao; - @Resource - private RedisDelayedQueue redisDelayedQueue; - @Resource - private AlihealthYljgUtils alihealthYljgUtils; - @Resource - private RelCodeBatchService relCodeBatchService; - @Resource - private RelCodeDetailService relCodeDetailService; - - - @Override - public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { - scheduledTaskRegistrar.addTriggerTask(() -> process(), - triggerContext -> { - ScheduledRequest scheduledRequest = new ScheduledRequest(); - scheduledRequest.setCronName("aliRelCodeDetailTask"); - ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); - if (scheduledEntity == null) { - return null; - } - String cron = scheduledEntity.getCron(); - if (cron.isEmpty()) { - logger.error("cron is null"); - } - return new CronTrigger(cron).nextExecutionTime(triggerContext); - }); - } - - private void process() { - - long currentTimestamp = System.currentTimeMillis() / 1000; // 当前时间戳(秒) - - // 获取所有超时的任务 (score <= 当前时间戳) - List tasksToProcess = redisDelayedQueue.getJedis().zrangeByScoreWithScores("rel_code_queue", "-inf", String.valueOf(currentTimestamp)); - - Iterator iterator = tasksToProcess.iterator(); - while (iterator.hasNext()) { - Tuple task = iterator.next(); - String taskId = task.getElement(); - String[] codes = taskId.split("&&&"); - if (codes!=null && codes.length>0) { - String code = codes[0]; - String erpId = codes[1]; - log.error("关联关系下载任务ID===" + code); - // 处理阿里关联关系 - relCodeBatchService.addRelCodeAli(code,erpId); - } - // 从队列中删除已执行的任务 - redisDelayedQueue.getJedis().zrem("rel_code_queue", taskId); - log.error("关联关系下载删除任务ID " + taskId + " removed from queue."); - } - } - -} +//package com.glxp.api.task; +// +//import cn.hutool.core.collection.CollUtil; +//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +//import com.glxp.api.common.res.BaseResponse; +//import com.glxp.api.dao.schedule.ScheduledDao; +//import com.glxp.api.entity.collect.RelCodeBatch; +//import com.glxp.api.entity.collect.RelCodeDetail; +//import com.glxp.api.entity.system.ScheduledEntity; +//import com.glxp.api.req.alihealth.AlihealthYljgSinglerelationReqeust; +//import com.glxp.api.req.system.ScheduledRequest; +//import com.glxp.api.res.alihealth.AlihealthYljgSinglerelationResponse; +//import com.glxp.api.service.collect.RelCodeBatchService; +//import com.glxp.api.service.collect.RelCodeDetailService; +//import com.glxp.api.util.CacheUtils; +//import com.glxp.api.util.DateUtil; +//import com.glxp.api.util.RedisUtil; +//import com.glxp.api.util.alihealth.AlihealthYljgUtils; +//import com.glxp.api.util.redis.RedisDelayedQueue; +//import lombok.extern.slf4j.Slf4j; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.scheduling.annotation.EnableScheduling; +//import org.springframework.scheduling.annotation.SchedulingConfigurer; +//import org.springframework.scheduling.config.ScheduledTaskRegistrar; +//import org.springframework.scheduling.support.CronTrigger; +//import org.springframework.stereotype.Component; +//import redis.clients.jedis.resps.Tuple; +// +//import javax.annotation.Resource; +//import java.util.*; +// +//@Component +//@EnableScheduling +//@Slf4j +//public class AliRelCodeDetailTask implements SchedulingConfigurer { +// +// final Logger logger = LoggerFactory.getLogger(AsyncDiDlTask.class); +// @Resource +// AsyncCompanyDlHelper udiCompanyTask; +// @Resource +// RedisUtil redisUtil; +// +// @Resource +// private ScheduledDao scheduledDao; +// @Resource +// private RedisDelayedQueue redisDelayedQueue; +// @Resource +// private AlihealthYljgUtils alihealthYljgUtils; +// @Resource +// private RelCodeBatchService relCodeBatchService; +// @Resource +// private RelCodeDetailService relCodeDetailService; +// +// +// @Override +// public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { +// scheduledTaskRegistrar.addTriggerTask(() -> process(), +// triggerContext -> { +// ScheduledRequest scheduledRequest = new ScheduledRequest(); +// scheduledRequest.setCronName("aliRelCodeDetailTask"); +// ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); +// if (scheduledEntity == null) { +// return null; +// } +// String cron = scheduledEntity.getCron(); +// if (cron.isEmpty()) { +// logger.error("cron is null"); +// } +// return new CronTrigger(cron).nextExecutionTime(triggerContext); +// }); +// } +// +// private void process() { +// +// long currentTimestamp = System.currentTimeMillis() / 1000; // 当前时间戳(秒) +// +// // 获取所有超时的任务 (score <= 当前时间戳) +// List tasksToProcess = redisDelayedQueue.getJedis().zrangeByScoreWithScores("rel_code_queue", "-inf", String.valueOf(currentTimestamp)); +// +// Iterator iterator = tasksToProcess.iterator(); +// while (iterator.hasNext()) { +// Tuple task = iterator.next(); +// String taskId = task.getElement(); +// String[] codes = taskId.split("&&&"); +// if (codes!=null && codes.length>0) { +// String code = codes[0]; +// String erpId = codes[1]; +// log.error("关联关系下载任务ID===" + code); +// // 处理阿里关联关系 +// relCodeBatchService.addRelCodeAli(code,erpId); +// } +// // 从队列中删除已执行的任务 +// redisDelayedQueue.getJedis().zrem("rel_code_queue", taskId); +// log.error("关联关系下载删除任务ID " + taskId + " removed from queue."); +// } +// } +// +//} diff --git a/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java b/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java index 8c3484f6..bcfb6125 100644 --- a/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java +++ b/src/main/java/com/glxp/api/util/alihealth/AlihealthYljgUtils.java @@ -66,31 +66,34 @@ public class AlihealthYljgUtils { new QueryWrapper().eq("erpId",erpId) ); if(basicCorpEntity!=null){ - AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse =null; - try { - AlihealthKytGetentinfoReqeust alihealthKytGetentinfoReqeust = new AlihealthKytGetentinfoReqeust(); - alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo"); - alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId()); - alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName()); - Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust,authCompany.getAppSecret()); - String json = HttpUtil.get(alihealthUrl,map); - alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json); - - }catch (Exception e){ - return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查"); - } + }else { + basicCorpEntity = new BasicCorpEntity(); + basicCorpEntity.setName(erpId); + } + AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse =null; + try { + AlihealthKytGetentinfoReqeust alihealthKytGetentinfoReqeust = new AlihealthKytGetentinfoReqeust(); + alihealthKytGetentinfoReqeust.setMethod("alibaba.alihealth.drugtrace.top.yljg.query.getentinfo"); + alihealthKytGetentinfoReqeust.setApp_key(authCompany.getAppId()); + alihealthKytGetentinfoReqeust.setEnt_name(basicCorpEntity.getName()); + Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust,authCompany.getAppSecret()); + String json = HttpUtil.get(alihealthUrl,map); + alihealthKytGetentinfoResponse =new AlihealthKytGetentinfoResponse(json); - if(StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info()) - && alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功") - ){ - reqeust.setFrom_user_id(alihealthKytGetentinfoResponse.getEnt_id()); - }else { - return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查==="+alihealthKytGetentinfoResponse.getMsg_info()); + }catch (Exception e){ + return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查"); - } } + if(StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info()) + && alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功") + ){ + reqeust.setFrom_user_id(alihealthKytGetentinfoResponse.getEnt_id()); + }else { + return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查==="+alihealthKytGetentinfoResponse.getMsg_info()); + + } } if (reqeust != null @@ -100,7 +103,9 @@ public class AlihealthYljgUtils { try { Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret()); String json = HttpUtil.get(alihealthUrl, map); - alihealthYljgUploadinoutbillResponse = JSONUtil.toBean(json, AlihealthYljgUploadinoutbillResponse.class); + log.error("阿里单据上传返回参数===" + json); + + alihealthYljgUploadinoutbillResponse = JSONUtil.toBean(json, AlihealthYljgUploadinoutbillResponse.class); } catch (Exception e) { return ResultVOUtils.error("阿里健康接口调用失败===" + e.getMessage()); diff --git a/src/main/resources/schemas/schema_v2.4.sql b/src/main/resources/schemas/schema_v2.4.sql index 1d1eca88..265cc015 100644 --- a/src/main/resources/schemas/schema_v2.4.sql +++ b/src/main/resources/schemas/schema_v2.4.sql @@ -1278,3 +1278,5 @@ ALTER TABLE rel_code_batch INSERT ignore INTO `sys_param_config` (`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, `paramType`, `paramExplain`, `updateTime`) VALUES (20101, 0, '新增送货单立即提交前置通过参数设置', 'create_order_pass_type', '3', 1, 0, '1:必须全部扫齐,才可以通过 2:必须选择了马上放心才能提交 3:必须有码才可以', NULL); + +INSERT ignore INTO `sys_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, `paramType`, `paramExplain`, `updateTime`) VALUES (90001, 0, '是否调用阿里关联关系模式', 'aliRelCodeDetail', '1', 1, 1, '值为0 是关闭 1是开启',now());