tujidelv 1 年之前
父節點
當前提交
4794716df6

+ 1 - 1
src/main/java/top/lvzhiqiang/config/MyCoinJobs.java

@@ -73,7 +73,7 @@ public class MyCoinJobs {
     @Scheduled(cron = "0 0 7 * * ?", zone = SCHEDULED_ZONE)
     public void syncCexFlag() {
         try {
-            coinService.syncCexFlag();
+            coinService.syncCexFlag(null);
         } catch (Exception e) {
         }
     }

+ 7 - 1
src/main/java/top/lvzhiqiang/controller/MusicInfoController.java

@@ -7,9 +7,11 @@ import top.lvzhiqiang.dto.MusicInfoQuery;
 import top.lvzhiqiang.dto.R;
 import top.lvzhiqiang.exception.ParameterException;
 import top.lvzhiqiang.service.MusicInfoService;
+import top.lvzhiqiang.util.DateUtils;
 import top.lvzhiqiang.util.StringUtils;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
 import java.util.HashMap;
 
 /**
@@ -60,7 +62,11 @@ public class MusicInfoController {
             qualityType = "low";
         }
 
-        return musicInfoService.insertOrUpdateImg(file, remark, categoryId, id, title, singer, issuingDate, collectionDate, qualityType);
+        if (StringUtils.isNotEmpty(issuingDate) && issuingDate.contains("年")) {
+            issuingDate = LocalDate.parse(issuingDate, DateUtils.dateFormatter3).format(DateUtils.dateFormatter);
+        }
+
+        return musicInfoService.insertOrUpdateMusic(file, remark, categoryId, id, title, singer, issuingDate, collectionDate, qualityType);
     }
 
     @RequestMapping("/deleteMusics/{musicId}")

+ 3 - 0
src/main/java/top/lvzhiqiang/mapper/CoinMapper.java

@@ -154,6 +154,9 @@ public interface CoinMapper {
     @Select("select * from coin_watchlist_other where symbol = #{symbol} and delete_flag = 1")
     CoinWatchlistOther findWatchlistOtherBySymbol(String symbol);
 
+    @Select("select a.*,b.coingecko_id from coin_watchlist_other a left join coin_watchlist b on a.symbol=b.symbol where a.symbol = #{symbol} and a.delete_flag = 1")
+    CoinWatchlistOther findWatchlistOtherBySymbol2(String symbol);
+
     @Insert({"<script>" +
             "INSERT INTO coin_watchlist_other(symbol,cex_spot,cex_perpetual,create_time,modify_time)" +
             " VALUES " +

+ 1 - 1
src/main/java/top/lvzhiqiang/service/CoinService.java

@@ -56,7 +56,7 @@ public interface CoinService {
 
     void debugTest();
 
-    void syncCexFlag();
+    void syncCexFlag(String symbol);
 
     void initWatchlist(CoinWatchlist coinWatchlist);
 }

+ 1 - 1
src/main/java/top/lvzhiqiang/service/MusicInfoService.java

@@ -19,7 +19,7 @@ public interface MusicInfoService {
      */
     Object getMusicInfoPage(Map<String, Object> params);
 
-    R insertOrUpdateImg(MultipartFile file, String remark, String categoryId, String id, String title, String singer, String issuingDate, String collectionDate, String qualityType);
+    R insertOrUpdateMusic(MultipartFile file, String remark, String categoryId, String id, String title, String singer, String issuingDate, String collectionDate, String qualityType);
 
     R deleteMusics(Long musicId);
 

+ 26 - 7
src/main/java/top/lvzhiqiang/service/impl/CoinServiceImpl.java

@@ -996,8 +996,19 @@ public class CoinServiceImpl implements CoinService {
      */
     @Override
     @Async
-    public void syncCexFlag() {
-        List<CoinWatchlistOther> watchlistOtherList = coinMapper.findAllCoinWatchlistOther();
+    public void syncCexFlag(String symbol) {
+        List<CoinWatchlistOther> watchlistOtherList;
+        if (StringUtils.isNotEmpty(symbol)) {
+            CoinWatchlistOther watchlistOther = coinMapper.findWatchlistOtherBySymbol2(symbol);
+            if (watchlistOther == null) {
+                return;
+            }
+
+            watchlistOtherList = new ArrayList<>();
+            watchlistOtherList.add(watchlistOther);
+        } else {
+            watchlistOtherList = coinMapper.findAllCoinWatchlistOther();
+        }
 
         // Perpetual
         String coingeckoExchangeFuturesTickersUrl = InitRunner.dicCodeMap.get("coingecko_exchange_futures_tickers_url").getCodeValue();
@@ -1189,8 +1200,13 @@ public class CoinServiceImpl implements CoinService {
                     JSONObject jsonObject = dataJO.getJSONObject(String.valueOf(key));
                     value.setTotalMarketRanking(jsonObject.getInteger("cmc_rank"));
 
-                    BigDecimal totalMarketValue = jsonObject.getJSONObject("quote").getJSONObject("USD").getBigDecimal("market_cap").setScale(2, RoundingMode.HALF_UP);
-                    if (totalMarketValue.compareTo(BigDecimal.ZERO) == 0) {
+                    BigDecimal totalMarketValue;
+                    try {
+                        totalMarketValue = jsonObject.getJSONObject("quote").getJSONObject("USD").getBigDecimal("market_cap").setScale(2, RoundingMode.HALF_UP);
+                        if (totalMarketValue.compareTo(BigDecimal.ZERO) == 0) {
+                            totalMarketValue = jsonObject.getBigDecimal("self_reported_market_cap").setScale(2, RoundingMode.HALF_UP);
+                        }
+                    } catch (Exception e) {
                         totalMarketValue = jsonObject.getBigDecimal("self_reported_market_cap").setScale(2, RoundingMode.HALF_UP);
                     }
                     value.setTotalMarketValue(totalMarketValue);
@@ -1224,13 +1240,13 @@ public class CoinServiceImpl implements CoinService {
                         coinWatchlistOther.setTotalSupply(jsonObject.getBigDecimal("total_supply").setScale(0, RoundingMode.HALF_UP).toPlainString());
                     }
                     JSONObject usdQuote = jsonObject.getJSONObject("quote").getJSONObject("USD");
-                    if (null != usdQuote.get("market_cap")) {
+                    if (usdQuote != null && null != usdQuote.get("market_cap")) {
                         coinWatchlistOther.setMarketCap(usdQuote.getBigDecimal("market_cap").setScale(0, RoundingMode.HALF_UP).toPlainString());
                         if ("0".equals(coinWatchlistOther.getMarketCap()) && null != jsonObject.get("self_reported_market_cap")) {
                             coinWatchlistOther.setMarketCap(jsonObject.getBigDecimal("self_reported_market_cap").setScale(0, RoundingMode.HALF_UP).toPlainString());
                         }
                     }
-                    if (null != usdQuote.get("fully_diluted_market_cap")) {
+                    if (usdQuote != null && null != usdQuote.get("fully_diluted_market_cap")) {
                         coinWatchlistOther.setFullyDilutedMarketCap(usdQuote.getBigDecimal("fully_diluted_market_cap").setScale(0, RoundingMode.HALF_UP).toPlainString());
                     }
 
@@ -2273,7 +2289,7 @@ public class CoinServiceImpl implements CoinService {
         //Map<Long, CoinWatchlist> coinWatchlistMap4CmcId = watchlistList.stream().collect(Collectors.toMap(CoinWatchlist::getCmcId, coinWatchlist -> coinWatchlist));
         // parseWatchlistMap4CmC(coinWatchlistMap4CmcId);
 
-        syncCexFlag();
+        syncCexFlag("PONKE");
     }
 
     @Override
@@ -2291,6 +2307,9 @@ public class CoinServiceImpl implements CoinService {
         List<CoinWatchlist> watchlistListCMC = coinMapper.findWatchlistList(params);
         Map<Long, CoinWatchlist> coinWatchlistMap4CmcId = watchlistListCMC.stream().collect(Collectors.toMap(CoinWatchlist::getCmcId, coinWatchlist -> coinWatchlist));
         parseWatchlistMap4CmC(coinWatchlistMap4CmcId);
+
+        // 初始化cexflag信息
+        syncCexFlag(coinWatchlist2.getSymbol());
     }
 
     public String convertHumanReadable(String number) {

+ 3 - 2
src/main/java/top/lvzhiqiang/service/impl/MusicInfoServiceImpl.java

@@ -50,7 +50,7 @@ public class MusicInfoServiceImpl extends BaseServiceImpl<Object> implements Mus
     }
 
     @Override
-    public R insertOrUpdateImg(MultipartFile file, String remark, String categoryId, String id, String title, String singer, String issuingDate, String collectionDate, String qualityType) {
+    public R insertOrUpdateMusic(MultipartFile file, String remark, String categoryId, String id, String title, String singer, String issuingDate, String collectionDate, String qualityType) {
         String imageUrl = "";
         String imageSize = "";
         String ftpBasePath = InitRunner.dicCodeMap.get("ftp_music_basepath").getCodeValue();
@@ -79,6 +79,7 @@ public class MusicInfoServiceImpl extends BaseServiceImpl<Object> implements Mus
                             tempFile = File.createTempFile("tempMp3", ".mp3");
                             file.transferTo(tempFile); // 将 MultipartFile 保存到临时文件
                             Mp3File mp3 = new Mp3File(tempFile.getAbsolutePath());
+                            log.warn("insertOrUpdateMusic Mp3File tempFile path={}", tempFile.getAbsolutePath());
                             long durationInMillis = mp3.getLengthInMilliseconds(); // 时长(毫秒)
                             // 转换为分:秒格式
                             long seconds = durationInMillis / 1000; // 转换为秒
@@ -148,7 +149,7 @@ public class MusicInfoServiceImpl extends BaseServiceImpl<Object> implements Mus
             } else if (fileMusicCollection.getIssuingDate() == null) {
                 parentPath = String.valueOf(LocalDate.now().getYear());
             } else {
-                parentPath = fileMusicCollection.getIssuingDate().format(DateUtils.dateFormatter);
+                parentPath = fileMusicCollection.getIssuingDate().format(DateUtils.dateFormatter).substring(0, 4);
             }
 
             try {

+ 1 - 1
src/main/resources/static/js/my-picture.js

@@ -111,7 +111,7 @@ function search(pageNo, startFlag, searchSelectFlag) {
         if (bigType == '爬虫') {
             genres = "福利吧";
             orderField = "fcil.publish_time";
-        } if (bigType == '上传') {
+        } else if (bigType == '上传') {
             genres = "";
             orderField = "fi.create_time";
         } else {