Browse Source

问题处理

yzc 1 year ago
parent
commit
5a8dd96673

+ 3 - 4
hx-common/src/main/java/com/fjhx/common/service/logistics/impl/LogisticsEndingAmountServiceImpl.java

@@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.PostConstruct;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
@@ -47,7 +46,7 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
     /**
      * 每月101分 赋值上月期末余额
      */
-    @PostConstruct
+//    @PostConstruct
     @Scheduled(cron = "0 1 0 1 * ?")
     public void autoSaveEndingAmount() {
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
@@ -68,7 +67,7 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
             String format = StrUtil.format("{}-{}", year, month);
             LogisticsEndingAmount one = this.getOne(q -> q
                     .eq(LogisticsEndingAmount::getLogisticsCompanyId, logisticsCompanyId)
-                    .apply("DATE_FORMAT(account_date,'%Y-%m') = {0}", format)
+                    .apply("DATE_FORMAT(account_date,'%Y-%m') = DATE_FORMAT( {0}, '%Y-%m' )", DateUtil.parse(format, "yyyy-MM"))
             );
             if (ObjectUtil.isEmpty(one)) {
                 one = new LogisticsEndingAmount();
@@ -113,7 +112,7 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
             String lastYearEndMonth = StrUtil.format("{}-12", dto.getYear() - 1);
             LogisticsEndingAmount lastYearEndAmount = this.getOne(q -> q
                     .eq(LogisticsEndingAmount::getLogisticsCompanyId, logisticsCompanyInfo.getId())
-                    .apply("DATE_FORMAT(account_date,'%Y-%m') = {0}", lastYearEndMonth)
+                    .apply("DATE_FORMAT(account_date,'%Y-%m') = DATE_FORMAT( {0}, '%Y-%m' )", DateUtil.parse(lastYearEndMonth, "yyyy-MM"))
             );
             if (ObjectUtil.isNotEmpty(lastYearEndAmount)) {
                 yearBeginBalance = lastYearEndAmount.getEndingBalance();