package com.qianwen.smartman.modules.smis.service; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import com.baomidou.mybatisplus.extension.service.IService; import com.qianwen.smartman.common.constant.ExtCacheConstant; import com.qianwen.smartman.common.enums.GlobalWcsTypeEnum; import com.qianwen.smartman.common.utils.Lambda; import com.qianwen.smartman.modules.smis.entity.GlobalWcs; import com.qianwen.smartman.modules.smis.vo.WcsAchievementsUpdateVO; import com.qianwen.smartman.modules.smis.vo.WcsAndAchievementsVO; public interface IGlobalWcsService extends IService { @Cacheable(cacheNames = {ExtCacheConstant.GLOBAL_WCS}, key = "'list:type:'+#globalWcsTypeEnum.type") List getGlobalWcsList(GlobalWcsTypeEnum globalWcsTypeEnum); List getWcsAndAchievements(); @Cacheable(cacheNames = {ExtCacheConstant.GLOBAL_WCS}, key = "'code:'.concat(#code) + ':type:'.concat(#globalWcsTypeEnum.type)") GlobalWcs getByCode(String code, GlobalWcsTypeEnum globalWcsTypeEnum); @CacheEvict(cacheNames = {ExtCacheConstant.GLOBAL_WCS}, allEntries = true) void updateWcsAndAchievements(WcsAchievementsUpdateVO wcsAchievements); @CacheEvict(cacheNames = {ExtCacheConstant.GLOBAL_WCS}, allEntries = true) boolean insertWcsAndAchievements(WcsAchievementsUpdateVO wcsAchievementsUpdateVO); @CacheEvict(cacheNames = {ExtCacheConstant.GLOBAL_WCS}, allEntries = true) default boolean removeByCode(String code, GlobalWcsTypeEnum typeEnum) { return remove(Lambda.eq(GlobalWcs::getCode, code).eq(GlobalWcs::getType, typeEnum.getType())); } @CacheEvict(cacheNames = {ExtCacheConstant.GLOBAL_WCS}, allEntries = true) default void updateWcsSeq(List codeList) { AtomicInteger seq = new AtomicInteger(1); codeList.forEach(code -> lambdaUpdate().set(GlobalWcs::getSeq, Integer.valueOf(seq.getAndIncrement())).eq(GlobalWcs::getCode, code).update()); /* codeList.forEach(code -> { ((LambdaUpdateChainWrapper) ((LambdaUpdateChainWrapper) lambdaUpdate().set((v0) -> { return v0.getSeq(); }, Integer.valueOf(seq.getAndIncrement()))).eq((v0) -> { return v0.getCode(); }, code)).update(); });*/ } }