Благодарю skn!
Вот что выходит, если вдруг кому понадобится. Динкод (5.2/6.0).
Код:
package ru.ellcom.test;
import java.sql.*;
import bitel.billing.server.admin.bean.ContractParameterPrefManager;
import bitel.billing.server.contract.bean.*;
import bitel.billing.server.util.MailMsg;
import ru.bitel.bgbilling.kernel.script.server.dev.GlobalScriptBase;
import ru.bitel.bgbilling.server.util.Setup;
import ru.bitel.common.sql.ConnectionSet;
public class MailNotice
extends GlobalScriptBase
{
@Override
public void execute(Setup setup, ConnectionSet connectionSet) throws Exception {
int cid = 0;
int[] textParamId = {1,3,6,31}; //ID текстовых параметров для проверки на вшивость
int[] addressParamId = {26}; //ID параметров типа адрес для проверки
StringBuilder report = new StringBuilder();
Connection con = connectionSet.getConnection();
ContractManager cm = new ContractManager(con);
ContractParameterManager cpm = new ContractParameterManager(con);
ContractParameterPrefManager cppm = new ContractParameterPrefManager(con);
String query = " SELECT c.id FROM contract AS c WHERE c.fc = 1 AND date2 IS NULL LIMIT 10 ";
PreparedStatement ps = con.prepareStatement( query );
ResultSet rs = ps.executeQuery();
while ( rs.next() )
{
cid = rs.getInt( 1 );
Contract contract = cm.getContractById(cid);
//Проверяем текстовые параметры
for( int i = 0; i < textParamId.length; i++){
if(cpm.getStringParam(cid, textParamId[i]) == null)
{
report.append( "В договоре " + contract.getTitle() + " не заполнен параметр " + cppm.getContractParameterPref(textParamId[i]).getTitle() + "\n" );
}
}
//Проверяем адресные параметры
for( int i = 0; i < addressParamId.length; i++){
if(cpm.getAddressParam(cid, addressParamId[i]) == null)
{
report.append( "В договоре " + contract.getTitle() + " не заполнен параметр " + cppm.getContractParameterPref(addressParamId[i]).getTitle() + "\n" );
}
}
}
rs.close();
ps.close();
MailMsg msg = new MailMsg( setup );
msg.sendMessage("blablabla@blabla.com", "Уведомление", "Здравствуйте! Необходимо проанализировать следующую информацию \n\n" + report.toString() );
}
}
на почту приходит
Цитата:
В договоре 101000239 не заполнен параметр Наименование банка
В договоре 101000239 не заполнен параметр Юридический адрес:
В договоре 101000252 не заполнен параметр Наименование банка
В договоре 101000252 не заполнен параметр Юридический адрес: