Prechádzať zdrojové kódy

修改数据库连接端口++同步代码加synchronized

songyh 3 rokov pred
rodič
commit
e32eb55ea4

+ 11 - 6
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -78,6 +78,13 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
     @Autowired
     @Autowired
     IAiBytedanceAutocreateLogService iBytedanceAutocreateLogService;
     IAiBytedanceAutocreateLogService iBytedanceAutocreateLogService;
 
 
+    private synchronized AiBytedanceAdDplinkInfo getlatestDpLinkInfo(AiBytedanceAdvertiserStrategy strategy,int status){
+        return adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),status);
+    }
+
+    private synchronized void saveDpLink(AiBytedanceAdDplinkInfo dplinkInfo){
+        adDplinkInfoService.save(dplinkInfo);
+    }
     @Override
     @Override
     public Long createCreative(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, Integer createType, Long videoCnt, String openUrl) {
     public Long createCreative(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, Integer createType, Long videoCnt, String openUrl) {
         UserAllocation userAllocation = userAllocationService.getByAccountId(strategy.getAccountId());
         UserAllocation userAllocation = userAllocationService.getByAccountId(strategy.getAccountId());
@@ -133,7 +140,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
             Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
             if(null==useDplinkIndex||useDplinkIndex.equals(0)){
             if(null==useDplinkIndex||useDplinkIndex.equals(0)){
                 //查看已使用的dp链接
                 //查看已使用的dp链接
-                AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
+                AiBytedanceAdDplinkInfo adDplinkInfo = getlatestDpLinkInfo(strategy,1);
                 if(null == adDplinkInfo){
                 if(null == adDplinkInfo){
                     adDplinkInfo = new AiBytedanceAdDplinkInfo();
                     adDplinkInfo = new AiBytedanceAdDplinkInfo();
                     if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
                     if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
@@ -206,7 +213,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adDplinkInfo.setStatus(1);
                 adDplinkInfo.setStatus(1);
                 adDplinkInfo.setStrategyId(strategy.getId());
                 adDplinkInfo.setStrategyId(strategy.getId());
                 adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
                 adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
-                adDplinkInfoService.save(adDplinkInfo);
+                saveDpLink(adDplinkInfo);
 
 
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
                 videoCreativeLogService.saveOrUpdate(creativeLog);
                 videoCreativeLogService.saveOrUpdate(creativeLog);
@@ -216,7 +223,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 }
                 }
             }else{
             }else{
                 Long dpIndex ;
                 Long dpIndex ;
-                AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
+                AiBytedanceAdDplinkInfo adDplinkInfo = getlatestDpLinkInfo(strategy,1);
                 if(null == adDplinkInfo){
                 if(null == adDplinkInfo){
                     adDplinkInfo = new AiBytedanceAdDplinkInfo();
                     adDplinkInfo = new AiBytedanceAdDplinkInfo();
                     if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
                     if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
@@ -255,10 +262,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
                 String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
                 //计划名称
                 //计划名称
                 String adName = getAdName(strategy,dplinkCode,video,userAllocation.getProjectId());
                 String adName = getAdName(strategy,dplinkCode,video,userAllocation.getProjectId());
-                log.info("计划原名称=============>>>>>>>>>>{};长度为{}",adName,StringUtils.length(adName));
                 //截取 计划名称
                 //截取 计划名称
                 adName = StringUtils.adNameSubMaterial(adName);
                 adName = StringUtils.adNameSubMaterial(adName);
-                log.info("计划截取后名称===========>>>>>>>>>>{};长度为{}",adName,StringUtils.length(adName));
                 //计算本次出价
                 //计算本次出价
                 BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
                 BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
                 adDplinkInfo.setAdBid(currentCpaBid);
                 adDplinkInfo.setAdBid(currentCpaBid);
@@ -305,7 +310,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adDplinkInfo.setStatus(1);
                 adDplinkInfo.setStatus(1);
                 adDplinkInfo.setStrategyId(strategy.getId());
                 adDplinkInfo.setStrategyId(strategy.getId());
                 adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
                 adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
-                adDplinkInfoService.save(adDplinkInfo);
+                saveDpLink(adDplinkInfo);
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
                 videoCreativeLogService.saveOrUpdate(creativeLog);
                 videoCreativeLogService.saveOrUpdate(creativeLog);
                 videoCnt --;
                 videoCnt --;