定时补救阿里单据上传和关联关系

dev_drug
qiuyt 1 month ago
parent ec6e25fa28
commit dad8c0605a

@ -13,6 +13,7 @@ import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType; import com.glxp.api.constant.BusinessType;
import com.glxp.api.controller.BaseController; import com.glxp.api.controller.BaseController;
import com.glxp.api.controller.inout.IoOrderReviewController;
import com.glxp.api.dao.inout.IoCodeDao; import com.glxp.api.dao.inout.IoCodeDao;
import com.glxp.api.entity.alihealth.AliYljgBillDetail; import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgSearchbill; 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.AlihealthKytDrugrescodeReqeust;
import com.glxp.api.req.alihealth.AlihealthKytGetentinfoReqeust; import com.glxp.api.req.alihealth.AlihealthKytGetentinfoReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgUploadinoutbillReqeust; 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.AlihealthGetRelCodeReqeust;
import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust; import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust;
import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; 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.AlihealthUtils;
import com.glxp.api.util.alihealth.AlihealthYljgUtils; import com.glxp.api.util.alihealth.AlihealthYljgUtils;
import com.glxp.api.util.alihealth.PaginationUtil; import com.glxp.api.util.alihealth.PaginationUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -100,14 +103,15 @@ public class AlihealthBusController extends BaseController {
} }
} }
@PostMapping("/spms/alihealth/thirdAliDrugList") @PostMapping("/spms/alihealth/thirdAliDrugList")
@Log(title = "获取阿里药品码段信息列表包括查询国家库", businessType = BusinessType.OTHER) @Log(title = "获取阿里药品码段信息列表包括查询国家库", businessType = BusinessType.OTHER)
public BaseResponse<PageSimpleResponse<ThirdAliDrug>> thirdAliDrugList(@RequestBody AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) { public BaseResponse<PageSimpleResponse<ThirdAliDrug>> thirdAliDrugList(@RequestBody AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) {
List<ThirdAliDrug> thirdAliDrugsListGjk = null; List<ThirdAliDrug> thirdAliDrugsListGjk = null;
PageSimpleResponse<ThirdAliDrug> pageSimpleResponse =new PageSimpleResponse(); PageSimpleResponse<ThirdAliDrug> pageSimpleResponse = new PageSimpleResponse();
// 本地查询和新增都先注释了 到时候加到这边来 // 本地查询和新增都先注释了 到时候加到这边来
YbDrug ybDrug = alihealthThirdAliDrugInsertReqeust.getYbDrug(); YbDrug ybDrug = alihealthThirdAliDrugInsertReqeust.getYbDrug();
if(alihealthThirdAliDrugInsertReqeust.isSelectCodeRelMark() && ybDrug!= null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())){ if (alihealthThirdAliDrugInsertReqeust.isSelectCodeRelMark() && ybDrug != null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())) {
// 用医保编码查询国家库药品信息 // 用医保编码查询国家库药品信息
try { try {
CodeRel codeReNew = new CodeRel(); CodeRel codeReNew = new CodeRel();
@ -117,13 +121,13 @@ public class AlihealthBusController extends BaseController {
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ThirdAliDrug>>>() { JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ThirdAliDrug>>>() {
}); });
if(responseListAndAliDrug.getCode() == 20000){ if (responseListAndAliDrug.getCode() == 20000) {
thirdAliDrugsListGjk = responseListAndAliDrug.getData(); thirdAliDrugsListGjk = responseListAndAliDrug.getData();
if(thirdAliDrugsListGjk != null && thirdAliDrugsListGjk.size() >0){ if (thirdAliDrugsListGjk != null && thirdAliDrugsListGjk.size() > 0) {
pageSimpleResponse.setList(thirdAliDrugsListGjk); pageSimpleResponse.setList(thirdAliDrugsListGjk);
return ResultVOUtils.success(pageSimpleResponse); return ResultVOUtils.success(pageSimpleResponse);
} }
}else { } else {
pageSimpleResponse.setList(thirdAliDrugsListGjk); pageSimpleResponse.setList(thirdAliDrugsListGjk);
return ResultVOUtils.success(pageSimpleResponse); return ResultVOUtils.success(pageSimpleResponse);
} }
@ -132,39 +136,39 @@ public class AlihealthBusController extends BaseController {
} }
}else { } else {
// 查询国家库药品信息 并且要插入到多玛融合表 // 查询国家库药品信息 并且要插入到多玛融合表
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust(); AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust();
ThirdAliDrugRequest thirdAliDrugRequest = new ThirdAliDrugRequest(); ThirdAliDrugRequest thirdAliDrugRequest = new ThirdAliDrugRequest();
BeanUtil.copyProperties(alihealthThirdAliDrugInsertReqeust,thirdAliDrugRequest); BeanUtil.copyProperties(alihealthThirdAliDrugInsertReqeust, thirdAliDrugRequest);
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getPhysic_name())) { if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getPhysic_name())) {
thirdAliDrugRequest.setCpmctymc(alihealthKytDrugrescodeReqeust.getPhysic_name()); thirdAliDrugRequest.setCpmctymc(alihealthKytDrugrescodeReqeust.getPhysic_name());
} }
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getApproval_licence_no())) { if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getApproval_licence_no())) {
thirdAliDrugRequest.setApprovalNum(alihealthKytDrugrescodeReqeust.getApproval_licence_no()); thirdAliDrugRequest.setApprovalNum(alihealthKytDrugrescodeReqeust.getApproval_licence_no());
} }
try { try {
String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", BeanUtil.beanToMap(thirdAliDrugRequest)); String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", BeanUtil.beanToMap(thirdAliDrugRequest));
BaseResponse<PageSimpleResponse<ThirdAliDrug>> udiDlDeviceResponse = BaseResponse<PageSimpleResponse<ThirdAliDrug>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThirdAliDrug>>>() { JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThirdAliDrug>>>() {
});
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());
});
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); return ResultVOUtils.success(pageSimpleResponse);
} }
pageSimpleResponse.setList(thirdAliDrugsListGjk); pageSimpleResponse.setList(thirdAliDrugsListGjk);
@ -234,6 +238,7 @@ public class AlihealthBusController extends BaseController {
AliYljgBillDetail aliYljgBillDetail = alihealthBusService.aliYljgBillDetail(aliYljgSearchbillReqeust); AliYljgBillDetail aliYljgBillDetail = alihealthBusService.aliYljgBillDetail(aliYljgSearchbillReqeust);
return ResultVOUtils.success(aliYljgBillDetail); return ResultVOUtils.success(aliYljgBillDetail);
} }
/** /**
* *
* *
@ -241,6 +246,7 @@ public class AlihealthBusController extends BaseController {
*/ */
@Resource @Resource
private RelCodeBatchService relCodeBatchService; private RelCodeBatchService relCodeBatchService;
@PostMapping("/spms/alihealth/getAliCode") @PostMapping("/spms/alihealth/getAliCode")
@Log(title = "阿里手动拉取完成单大级码没有关联关系的接口", businessType = BusinessType.OTHER) @Log(title = "阿里手动拉取完成单大级码没有关联关系的接口", businessType = BusinessType.OTHER)
public BaseResponse getAliCode(@RequestBody AlihealthGetRelCodeReqeust alihealthGetRelCodeReqeust) { public BaseResponse getAliCode(@RequestBody AlihealthGetRelCodeReqeust alihealthGetRelCodeReqeust) {
@ -251,45 +257,18 @@ public class AlihealthBusController extends BaseController {
return ResultVOUtils.success("成功"); return ResultVOUtils.success("成功");
} }
@Resource @Resource
private IoCodeDao ioCodeDao; private IoOrderReviewController ioOrderReviewController;
@Resource @PostMapping("/spms/alihealth/aliBillsDispose")
private AlihealthYljgUtils alihealthYljgUtils; @Log(title = "手动调用阿里单据上传和关联关系拉取", businessType = BusinessType.OTHER)
@PostMapping("/spms/alihealth/yljgUploadinoutbill") public BaseResponse aliBillsDispose(@RequestBody AliBillsDisposeReqeust aliBillsDisposeReqeust) {
@Log(title = "获取阿里药品的采购单码明细", businessType = BusinessType.OTHER)
public BaseResponse yljgUploadinoutbill(@RequestBody AlihealthGetRelCodeReqeust alihealthGetRelCodeReqeust) { List<IoOrderEntity> ioOrderEntityList = aliBillsDisposeReqeust.getIoOrderEntityList();
log.error("开始补救上传和拉取关联关系列表==="+ioOrderEntityList);
List<String> list = new ArrayList<>();
list.add("ZS202502170071"); for (IoOrderEntity ioOrderEntity : ioOrderEntityList) {
list.add("ZS202502180035"); ioOrderReviewController.aliBillsDispose(ioOrderEntity);
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<IoCodeEntity> ioCodeEntityList = ioCodeDao.selectList(new QueryWrapper<IoCodeEntity>().eq("orderId", orderEntity.getBillNo()));
if (ioCodeEntityList != null && ioCodeEntityList.size() > 0) {
List<String> codeList = new ArrayList<>();
for (IoCodeEntity ioCodeEntity : ioCodeEntityList) {
codeList.add(ioCodeEntity.getCode());
}
Set<String> set = new HashSet<>(codeList);
alihealthYljgUploadinoutbillReqeust.setTrace_codes(String.join(",", codeList));
// 单据上传先注释了
BaseResponse baseResponseUploadinoutbill = alihealthYljgUtils.yljgUploadinoutbill(alihealthYljgUploadinoutbillReqeust, orderEntity.getFromCorp());
}
} }

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation; 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.ConstantStatus;
import com.glxp.api.constant.ConstantType; import com.glxp.api.constant.ConstantType;
import com.glxp.api.controller.BaseController; 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.IoCodeDao;
import com.glxp.api.dao.inout.IoCodeTempDao; import com.glxp.api.dao.inout.IoCodeTempDao;
import com.glxp.api.entity.auth.AuthAdmin; import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity; 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.basic.EntrustReceEntity;
import com.glxp.api.entity.collect.RelCodeBatch; import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.inout.*; 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.*;
import com.glxp.api.util.alihealth.AlihealthYljgUtils; import com.glxp.api.util.alihealth.AlihealthYljgUtils;
import com.glxp.api.util.redis.RedisDelayedQueue; import com.glxp.api.util.redis.RedisDelayedQueue;
import com.glxp.api.util.udi.FilterUdiUtils;
import com.glxp.api.util.udi.UdiCalCountUtil; import com.glxp.api.util.udi.UdiCalCountUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
@ -155,9 +160,12 @@ public class IoOrderReviewController extends BaseController {
//todo 审核通过上传关联关系 //todo 审核通过上传关联关系
BasicBussinessTypeEntity businessType = basicBussinessTypeService.findByAction(orderEntity.getAction()); BasicBussinessTypeEntity businessType = basicBussinessTypeService.findByAction(orderEntity.getAction());
log.error("单据审核进来了===businessType====" + businessType); log.error("单据审核进来了===businessType====" + businessType);
String paramValue = systemParamConfigService.selectValueByParamKey("aliRelCodeDetail");
if (businessType.getCorpType() == ConstantStatus.CORP_SP && businessType.getMainAction().equals(ConstantType.TYPE_PUT) && businessType.getProductType() == 2) { if (businessType.getCorpType() == ConstantStatus.CORP_SP && businessType.getMainAction().equals(ConstantType.TYPE_PUT) && businessType.getProductType() == 2
aliBillsDispose(orderEntity); && StrUtil.isNotEmpty(paramValue) && paramValue.equals("1")) {
ThreadUtil.execAsync(() -> {
aliBillsDispose(orderEntity);
});
} }
} }
return baseResponse; return baseResponse;
@ -469,44 +477,70 @@ public class IoOrderReviewController extends BaseController {
private Integer relCodeDelaySeconds; private Integer relCodeDelaySeconds;
@Resource @Resource
private RedisDelayedQueue redisDelayedQueue; private RedisDelayedQueue redisDelayedQueue;
@Resource
private BasicProductsDao basicProductsDao;
// 异步处理阿里单据 // 异步处理阿里单据
public BaseResponse aliBillsDispose(IoOrderEntity orderEntity) { 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<IoCodeEntity> ioCodeEntityList = ioCodeDao.selectList(new QueryWrapper<IoCodeEntity>().eq("orderId", orderEntity.getBillNo())); List<IoCodeEntity> ioCodeEntityList = ioCodeDao.selectList(new QueryWrapper<IoCodeEntity>().eq("orderId", orderEntity.getBillNo()));
if (ioCodeEntityList != null && ioCodeEntityList.size() > 0) { if (ioCodeEntityList != null && ioCodeEntityList.size() > 0) {
List<String> codeList = new ArrayList<>(); int chunkSize = 250;
for (IoCodeEntity ioCodeEntity : ioCodeEntityList) { List<List<IoCodeEntity>> ioCodeEntityChunks = Lists.partition(ioCodeEntityList, chunkSize);
codeList.add(ioCodeEntity.getCode()); for (int i = 0; i < ioCodeEntityChunks.size(); i++) {
} List<IoCodeEntity> ioCodeEntityChunk = ioCodeEntityChunks.get(i);
Set<String> set = new HashSet<>(codeList); //1.上传入库单
alihealthYljgUploadinoutbillReqeust.setTrace_codes(String.join(",", codeList)); AlihealthYljgUploadinoutbillReqeust alihealthYljgUploadinoutbillReqeust = new AlihealthYljgUploadinoutbillReqeust();
// 单据上传先注释了 // 单据号处理
BaseResponse baseResponseUploadinoutbill = alihealthYljgUtils.yljgUploadinoutbill(alihealthYljgUploadinoutbillReqeust,orderEntity.getFromCorp()); if (ioCodeEntityChunks.size() < 2) {
log.error("要查询阿里关联关系的码===" + set); alihealthYljgUploadinoutbillReqeust.setBill_code(orderEntity.getBillNo());
String erpId = orderEntity.getFromCorp();
for (String code : set) {
relCodeBatchService.addRelCodeAli(code, orderEntity.getFromCorp());
RelCodeBatch relCodeBatch = relCodeBatchService.getOne(
new QueryWrapper<RelCodeBatch>().eq("curCode", code)
);
if (Objects.isNull(relCodeBatch)) {
redisDelayedQueue.addTaskToQueue(code + "&&&" + erpId, relCodeDelaySeconds, "rel_code_queue");
} else { } 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<String> codeList = new ArrayList<>();
for (IoCodeEntity ioCodeEntity : ioCodeEntityChunk) {
codeList.add(ioCodeEntity.getCode());
}
Set<String> 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<BasicProductsEntity>()
.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<RelCodeBatch>().eq("curCode", code)
// );
// if (Objects.isNull(relCodeBatch)) {
// if(queueBo){
// redisDelayedQueue.addTaskToQueue(code + "&&&" + erpId, relCodeDelaySeconds, "rel_code_queue");
// }
// } else {
// log.error("有关联关系了此码===" + code);
// }
}
} }
} }
} }
});
return ResultVOUtils.success("更新成功"); return ResultVOUtils.success("更新成功");
} }

@ -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<IoOrderEntity> ioOrderEntityList;
}

@ -1,99 +1,99 @@
package com.glxp.api.task; //package com.glxp.api.task;
//
import cn.hutool.core.collection.CollUtil; //import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; //import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.glxp.api.common.res.BaseResponse; //import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.dao.schedule.ScheduledDao; //import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.entity.collect.RelCodeBatch; //import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.collect.RelCodeDetail; //import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.entity.system.ScheduledEntity; //import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.req.alihealth.AlihealthYljgSinglerelationReqeust; //import com.glxp.api.req.alihealth.AlihealthYljgSinglerelationReqeust;
import com.glxp.api.req.system.ScheduledRequest; //import com.glxp.api.req.system.ScheduledRequest;
import com.glxp.api.res.alihealth.AlihealthYljgSinglerelationResponse; //import com.glxp.api.res.alihealth.AlihealthYljgSinglerelationResponse;
import com.glxp.api.service.collect.RelCodeBatchService; //import com.glxp.api.service.collect.RelCodeBatchService;
import com.glxp.api.service.collect.RelCodeDetailService; //import com.glxp.api.service.collect.RelCodeDetailService;
import com.glxp.api.util.CacheUtils; //import com.glxp.api.util.CacheUtils;
import com.glxp.api.util.DateUtil; //import com.glxp.api.util.DateUtil;
import com.glxp.api.util.RedisUtil; //import com.glxp.api.util.RedisUtil;
import com.glxp.api.util.alihealth.AlihealthYljgUtils; //import com.glxp.api.util.alihealth.AlihealthYljgUtils;
import com.glxp.api.util.redis.RedisDelayedQueue; //import com.glxp.api.util.redis.RedisDelayedQueue;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; //import org.slf4j.Logger;
import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling; //import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer; //import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger; //import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import redis.clients.jedis.resps.Tuple; //import redis.clients.jedis.resps.Tuple;
//
import javax.annotation.Resource; //import javax.annotation.Resource;
import java.util.*; //import java.util.*;
//
@Component //@Component
@EnableScheduling //@EnableScheduling
@Slf4j //@Slf4j
public class AliRelCodeDetailTask implements SchedulingConfigurer { //public class AliRelCodeDetailTask implements SchedulingConfigurer {
//
final Logger logger = LoggerFactory.getLogger(AsyncDiDlTask.class); // final Logger logger = LoggerFactory.getLogger(AsyncDiDlTask.class);
@Resource // @Resource
AsyncCompanyDlHelper udiCompanyTask; // AsyncCompanyDlHelper udiCompanyTask;
@Resource // @Resource
RedisUtil redisUtil; // RedisUtil redisUtil;
//
@Resource // @Resource
private ScheduledDao scheduledDao; // private ScheduledDao scheduledDao;
@Resource // @Resource
private RedisDelayedQueue redisDelayedQueue; // private RedisDelayedQueue redisDelayedQueue;
@Resource // @Resource
private AlihealthYljgUtils alihealthYljgUtils; // private AlihealthYljgUtils alihealthYljgUtils;
@Resource // @Resource
private RelCodeBatchService relCodeBatchService; // private RelCodeBatchService relCodeBatchService;
@Resource // @Resource
private RelCodeDetailService relCodeDetailService; // private RelCodeDetailService relCodeDetailService;
//
//
@Override // @Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { // public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(), // scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> { // triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest(); // ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("aliRelCodeDetailTask"); // scheduledRequest.setCronName("aliRelCodeDetailTask");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); // ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
if (scheduledEntity == null) { // if (scheduledEntity == null) {
return null; // return null;
} // }
String cron = scheduledEntity.getCron(); // String cron = scheduledEntity.getCron();
if (cron.isEmpty()) { // if (cron.isEmpty()) {
logger.error("cron is null"); // logger.error("cron is null");
} // }
return new CronTrigger(cron).nextExecutionTime(triggerContext); // return new CronTrigger(cron).nextExecutionTime(triggerContext);
}); // });
} // }
//
private void process() { // private void process() {
//
long currentTimestamp = System.currentTimeMillis() / 1000; // 当前时间戳(秒) // long currentTimestamp = System.currentTimeMillis() / 1000; // 当前时间戳(秒)
//
// 获取所有超时的任务 (score <= 当前时间戳) // // 获取所有超时的任务 (score <= 当前时间戳)
List<Tuple> tasksToProcess = redisDelayedQueue.getJedis().zrangeByScoreWithScores("rel_code_queue", "-inf", String.valueOf(currentTimestamp)); // List<Tuple> tasksToProcess = redisDelayedQueue.getJedis().zrangeByScoreWithScores("rel_code_queue", "-inf", String.valueOf(currentTimestamp));
//
Iterator<Tuple> iterator = tasksToProcess.iterator(); // Iterator<Tuple> iterator = tasksToProcess.iterator();
while (iterator.hasNext()) { // while (iterator.hasNext()) {
Tuple task = iterator.next(); // Tuple task = iterator.next();
String taskId = task.getElement(); // String taskId = task.getElement();
String[] codes = taskId.split("&&&"); // String[] codes = taskId.split("&&&");
if (codes!=null && codes.length>0) { // if (codes!=null && codes.length>0) {
String code = codes[0]; // String code = codes[0];
String erpId = codes[1]; // String erpId = codes[1];
log.error("关联关系下载任务ID===" + code); // log.error("关联关系下载任务ID===" + code);
// 处理阿里关联关系 // // 处理阿里关联关系
relCodeBatchService.addRelCodeAli(code,erpId); // relCodeBatchService.addRelCodeAli(code,erpId);
} // }
// 从队列中删除已执行的任务 // // 从队列中删除已执行的任务
redisDelayedQueue.getJedis().zrem("rel_code_queue", taskId); // redisDelayedQueue.getJedis().zrem("rel_code_queue", taskId);
log.error("关联关系下载删除任务ID " + taskId + " removed from queue."); // log.error("关联关系下载删除任务ID " + taskId + " removed from queue.");
} // }
} // }
//
} //}

@ -66,31 +66,34 @@ public class AlihealthYljgUtils {
new QueryWrapper<BasicCorpEntity>().eq("erpId",erpId) new QueryWrapper<BasicCorpEntity>().eq("erpId",erpId)
); );
if(basicCorpEntity!=null){ 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()) }catch (Exception e){
&& alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功") return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查");
){
reqeust.setFrom_user_id(alihealthKytGetentinfoResponse.getEnt_id());
}else {
return ResultVOUtils.error("阿里健康接口调用失败===往来单位名称请检查==="+alihealthKytGetentinfoResponse.getMsg_info());
}
} }
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 if (reqeust != null
@ -100,7 +103,9 @@ public class AlihealthYljgUtils {
try { try {
Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret()); Map map = alihealthUtils.disposeSign(reqeust, authCompany.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map); String json = HttpUtil.get(alihealthUrl, map);
alihealthYljgUploadinoutbillResponse = JSONUtil.toBean(json, AlihealthYljgUploadinoutbillResponse.class); log.error("阿里单据上传返回参数===" + json);
alihealthYljgUploadinoutbillResponse = JSONUtil.toBean(json, AlihealthYljgUploadinoutbillResponse.class);
} catch (Exception e) { } catch (Exception e) {
return ResultVOUtils.error("阿里健康接口调用失败===" + e.getMessage()); return ResultVOUtils.error("阿里健康接口调用失败===" + e.getMessage());

@ -1278,3 +1278,5 @@ ALTER TABLE rel_code_batch
INSERT ignore INTO `sys_param_config` (`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, `paramType`, `paramExplain`, `updateTime`) 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); 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());

Loading…
Cancel
Save