Created
January 26, 2024 09:00
-
-
Save SinTeZWh1te/b80dfae7d68f709b9cc97a32c4ce02c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.test.bgbilling.kernel.scripts.global; | |
import org.apache.logging.log4j.LogManager; | |
import org.apache.logging.log4j.Logger; | |
import ru.bitel.bgbilling.kernel.script.server.dev.GlobalScriptBase; | |
import ru.bitel.bgbilling.kernel.task.server.bean.RunTaskDataManager; | |
import ru.bitel.bgbilling.modules.npay.server.Recalculator; | |
import ru.bitel.bgbilling.modules.npay.server.bean.RecalculatorParameters; | |
import ru.bitel.bgbilling.server.util.Setup; | |
import ru.bitel.common.TimeUtils; | |
import ru.bitel.common.sql.ConnectionSet; | |
import java.sql.Connection; | |
import java.sql.PreparedStatement; | |
import java.sql.ResultSet; | |
import java.util.ArrayList; | |
import java.util.Calendar; | |
import java.util.GregorianCalendar; | |
import java.util.List; | |
/** | |
* @author sintezwh1te | |
*/ | |
public class Test5 | |
extends GlobalScriptBase { | |
private static final Logger logger = LogManager.getLogger(); | |
private static final int NPAY_MID = 1; | |
@Override | |
public void execute(Setup setup, ConnectionSet connectionSet) | |
throws Exception { | |
Connection con = connectionSet.getConnection(); | |
Calendar calFrom = new GregorianCalendar(2020, Calendar.JANUARY, 1); | |
Calendar calTo = new GregorianCalendar(2024, Calendar.JANUARY, 31); | |
String query = """ | |
SELECT id FROM contract WHERE id = 1 | |
"""; | |
List<Integer> contractIds = new ArrayList<>(100); | |
try (PreparedStatement ps = con.prepareStatement(query); | |
ResultSet rs = ps.executeQuery()) { | |
while (rs.next()) { | |
contractIds.add(rs.getInt("id")); | |
} | |
} | |
while (TimeUtils.dateBefore(calFrom, calTo)) { | |
new RunTaskDataManager(con).addTask(new Recalculator(NPAY_MID, calFrom, RecalculatorParameters.builder().setServiceSet(0).setEmail("").setDetail(false).setContractIds(contractIds).setComment("").build())); | |
calFrom.add(Calendar.MONTH, 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment