fix:暂时取消定时任务,手动查询需要更新的阿里数据进行写死时间的过滤

v3
chenhc 3 months ago
parent a758dca19b
commit 8c4dd7ee60

@ -37,4 +37,17 @@ public class AuthAliUser {
*/
@TableField(value = "type")
private String type;
/**
*
*/
@TableField(value = "drugResCodeCount")
private Integer drugResCodeCount;
/**
*
*/
@TableField(value = "drugResCodeCountMax")
private Integer drugResCodeCountMax;
}

@ -0,0 +1,50 @@
package com.glxp.udidl.admin.thread;
import com.glxp.udidl.admin.dao.info.ScheduledMapper;
import com.glxp.udidl.admin.entity.auth.AuthAliUser;
import com.glxp.udidl.admin.entity.info.ScheduledEntity;
import com.glxp.udidl.admin.req.info.ScheduledRequest;
import com.glxp.udidl.admin.service.auth.AuthAliUserService;
import com.glxp.udidl.admin.service.chsapi.ChsYbHcxxService;
import com.glxp.udidl.admin.service.collect.ThirdAliDrugService;
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 javax.annotation.Resource;
@Component
@EnableScheduling
public class ThirdAliDrugClearResCodeCountTask implements SchedulingConfigurer {
@Resource
private AuthAliUserService authAliUserService;
final Logger logger = LoggerFactory.getLogger(ThirdAliDrugClearResCodeCountTask.class);
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> {
String cron = "0 0 * * * ?";//每天0点
if (cron.isEmpty()) {
logger.error("cron is null");
}
return new CronTrigger(cron).nextExecutionTime(triggerContext);
});
}
private void process() {
System.out.println("开始执行更新阿里健康数据访问重置");
AuthAliUser one = authAliUserService.getOne();
one.setDrugResCodeCount(0);
authAliUserService.updateById(one);
}
}

@ -6,6 +6,7 @@ import cn.hutool.http.HttpUtil;
import com.glxp.udidl.admin.constant.AliConstants;
import com.glxp.udidl.admin.entity.auth.AuthAliUser;
import com.glxp.udidl.admin.entity.collect.ThirdAliDrug;
import com.glxp.udidl.admin.exception.JsonException;
import com.glxp.udidl.admin.req.alihealth.AlihealthKytCommonParametersReqeust;
import com.glxp.udidl.admin.req.alihealth.AlihealthKytDrugrescodeReqeust;
import com.glxp.udidl.admin.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust;
@ -148,6 +149,17 @@ public class AlihealthUtils {
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust();
// key组装
AuthAliUser authAliUser = authAliUserService.getOne();
//增加次数限制
Integer drugResCodeCount = authAliUser.getDrugResCodeCount();
Integer drugResCodeCountMax = authAliUser.getDrugResCodeCountMax();
if (drugResCodeCount >= drugResCodeCountMax){
throw new JsonException("当前系统调用阿里药品数据查询接口最大次数已达到,禁止访问,如需访问请联系管理员增加访问次数!");
}
drugResCodeCount = drugResCodeCount + 1;
authAliUser.setDrugResCodeCount(drugResCodeCount);
authAliUserService.updateById(authAliUser);
alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid());
alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret());
alihealthKytDrugrescodeReqeust.setApp_key(authAliUser.getAppkey());

@ -341,6 +341,8 @@ CREATE TABLE IF NOT EXISTS `auth_ali_user`
`appSecret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '阿里密钥',
`refEntId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '厂家标识',
`type` varchar(255) DEFAULT NULL COMMENT '1 为生成企业 2为零售药店',
`drugResCodeCount` int DEFAULT 0 COMMENT '药品查询接口次数',
`drugResCodeCountMax` int DEFAULT 0 COMMENT '药品查询接口允许最大次数',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4

Loading…
Cancel
Save