提交 82b11240 作者: gh

Merge remote-tracking branch 'origin/master'

......@@ -6,9 +6,11 @@ import com.rabbitmq.client.Channel;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.constants.RabbitCommonNameConstant;
import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.AccountOrderService;
import com.yaoyaozw.customer.service.CustomerDelayPublishService;
import com.yaoyaozw.customer.service.CustomerGraphicsService;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.ChannelCallback;
......@@ -20,6 +22,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author wgh
......@@ -30,6 +35,8 @@ import java.util.Calendar;
@RequestMapping("/customer-service/test")
public class TestController {
private final static String STORE_ENTITY_REDIS_KEY = "STORE_NAME_MAP";
@Autowired
private CustomerGraphicsService customerGraphicsService;
@Autowired
......@@ -40,6 +47,8 @@ public class TestController {
private RabbitTemplate rabbitTemplate;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@GetMapping("/CustomerTest")
public void test(){
......@@ -85,52 +94,12 @@ public class TestController {
accountOrderService.activeUserByOrder(integrationRequestDTO);
}
@GetMapping("/ygLimit")
public void ygLimit(){
limit();
}
private void limit() {
boolean go;
synchronized (rabbitTemplate) {
// 从redis查询计数
Object count = redisTemplate.opsForValue().get(CustomerCommonConstant.YANG_GUANG_ACCESS_LIMIT_REDIS_KEY);
if (ObjectUtil.isNull(count)) {
// redis中没有,设置0
redisTemplate.opsForValue().set(CustomerCommonConstant.YANG_GUANG_ACCESS_LIMIT_REDIS_KEY, 0);
count = 0;
}
log.info("当前count: {}", count);
long stamp = System.currentTimeMillis();
// 判断计数是否达到上限
go = (Integer)count < 40;
if (go) {
// 没有达到上限,发送消息并且计数加1
rabbitTemplate.convertAndSend(RabbitCommonNameConstant.OPERATE_COMMON_EXCHANGE, RabbitCommonNameConstant.YG_LIMIT_TTL_ROUTE_KEY, stamp);
redisTemplate.opsForValue().increment(CustomerCommonConstant.YANG_GUANG_ACCESS_LIMIT_REDIS_KEY);
}
}
if (!go) {
// 计数达到上限了,休眠30秒,递归调用
try {
log.info("达到上限, 休眠15秒");
Thread.sleep(15000);
limit();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@GetMapping("/putRedisStore")
public void redisStore() {
List<AuthInfoVO> allStoreList = kanbanCommonMapper.getAllStoreList();
Map<String, String> storeMap = allStoreList.stream().collect(Collectors.toMap(AuthInfoVO::getStoreType, AuthInfoVO::getStoreTypeName));
redisTemplate.opsForHash().putAll(STORE_ENTITY_REDIS_KEY, storeMap);
@RabbitListener(queues = RabbitCommonNameConstant.YG_LIMIT_DEATH_QUEUE)
public void listener() {
log.info("消费");
redisTemplate.opsForValue().decrement(CustomerCommonConstant.YANG_GUANG_ACCESS_LIMIT_REDIS_KEY);
}
}
......@@ -14,8 +14,8 @@ public enum CustomerStoreTemplateEnum {
YANG_GUANG("YANG_GUANG", "5"),
YUE_WEN("YUE_WEN", "1"),
ZHANG_ZHONG_YUN("ZHANG_ZHONG_YUN", "1"),
ZHANG_DU("ZHANG_DU", "1")
ZHANG_ZHONG_YUN("ZHANG_ZHONG_YUN", "15"),
ZHANG_DU("ZHANG_DU", "0")
;
......
......@@ -2,6 +2,7 @@ package com.yaoyaozw.customer.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.yaoyaozw.customer.entity.CrowdPackageCondition;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.kanban.CommonCostSetupVo;
import com.yaoyaozw.customer.vo.kanban.CommonOptionResponseVO;
import org.apache.ibatis.annotations.Param;
......@@ -55,4 +56,9 @@ public interface KanbanCommonMapper {
List<CommonCostSetupVo> getWechatCostSetup(@Param("appid")String appid);
/**
* @return {@link List}<{@link AuthInfoVO}>
*/
List<AuthInfoVO> getAllStoreList();
}
......@@ -272,8 +272,6 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
if (CollectionUtil.isNotEmpty(resultList)) {
super.updateBatchById(resultList);
}
LOCAL_LOG.info("删除创建时的临时数据");
super.remove(new QueryWrapper<CrowdPackage>().isNull("package_name"));
}
/**
......
......@@ -51,4 +51,11 @@
</select>
<select id="getAllStoreList" resultType="com.yaoyaozw.customer.vo.AuthInfoVO">
select
store_name as storeTypeName,
store_type as storeType
from store_entity
where is_deleted = 0 and pct_type = 'PROFIT_PCT'
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论