MyTetra Share
Делитесь знаниями!
Отмена оплат арендодателями по выгрузке
Время создания: 06.07.2020 12:22
Раздел: INFO - JOB - rtneo - Выгрузки - УПД
Запись: wwwlir/Tetra/master/base/1594009357lajep1gfy0/text.html на raw.githubusercontent.com

import com.groupstp.rtneo.entity.*

import java.util.*

import com.haulmont.cuba.core.global.*

import com.groupstp.rtneo.entity.*

import com.haulmont.cuba.core.entity.FileDescriptor

import com.haulmont.cuba.core.app.FileStorageAPI

import java.io.InputStream

import java.io.InputStreamReader

import java.io.ByteArrayOutputStream

import org.apache.commons.io.IOUtils

import java.nio.charset.StandardCharsets;

import com.opencsv.CSVReader;

import com.groupstp.rtneo.service.BillService

import java.text.SimpleDateFormat

import org.apache.commons.collections.CollectionUtils



DataManager dataManager = AppBeans.get(DataManager.NAME)

FileStorageAPI fileStorageAPI=AppBeans.get(FileStorageAPI.NAME);

BillService billService = AppBeans.get(BillService.NAME)



String id='226ff0f4-353e-a518-bb74-cfee755c8ef5'



FileDescriptor fd = dataManager.load(FileDescriptor.class)

.id(UuidProvider.fromString(id))

.view(View.MINIMAL)

.optional()

.orElse(null);

if (fd == null) {

throw new RuntimeException("fileNotFound");

}

InputStream inputStream=fileStorageAPI.openStream(fd)

CSVReader reader = new CSVReader(new InputStreamReader(inputStream, "UTF-8"));

List<String> listInn = [];

for(row in reader)

{

listInn.add(row[0])

}



//def list = dataManager.loadValues('select c.id, c.inn, c.personalAccount, size(c.contracts) from rtneo$Contragent c where c.inn in :listInn and (select count(ct) from rtneo$Contract ct where ct.contragent = c and ct.loadedFromBigTrio = true)=0 order by c.inn, size(c.contracts)')

// .properties("id", "inn", "pa", "count")

// .parameter("listInn" , listInn)

// .list()

//def list = dataManager.loadValues('select r, c.personalAccount, r.contragent.personalAccount, r.payOwner from rtneo$RealEstateRenter r join rtneo$Contragent c on r.contragentRealEstate.contragent = c where c.inn in :listInn and r.payOwner = true')

// .properties("id", "inn", "pa", "count")

// .parameter("listInn" , listInn)

// .list()


def list = dataManager.load(RealEstateRenter.class)

.query('select r from rtneo$RealEstateRenter r join rtneo$Contragent c on r.contragentRealEstate.contragent = c where c.inn in :listInn and r.payOwner = true')

.parameter("listInn" , listInn)

.view("_local")

.list()


CommitContext commitContext = new CommitContext()


for(def item : list){

// _("${item.getValue('id')}(${item.getValue('inn')}) - ${item.getValue('pa')}, count - ${item.getValue('count')}")

RealEstateRenter rr = item

item.setPayOwner(false)

commitContext.addInstanceToCommit(rr)

}

dataManager.commit(commitContext)

/**

* Логирование

*/

import com.haulmont.cuba.core.app.serialization.EntitySerializationAPI;

import com.groupstp.rtneo.util.JsonUtil;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

private _(Object obj, String... options){

if(obj == null){log("LOG.ERROR: Object is null!!!");return}

if(options.size() == 0){log(obj)}

for(def option : options){

if(option.equals("str")){log(obj)}

if(option.equals("for")){obj.each({_(it)})}

if(option.equals("json")){

EntitySerializationAPI entitySerializationAPI = AppBeans.get(EntitySerializationAPI.NAME)

try{log(entitySerializationAPI.toJson(obj))}

catch(Exception e){log("LOG.ERROR: JSON entity serialization failed")}

}

if(option.equals("objJson")){

JsonUtil jsonUtil = AppBeans.get(JsonUtil.NAME)

try{log.(jsonUtil.toJson(obj))}

catch(Exception e){log("LOG.ERROR: JSON object serialization failed")}

}

if(option.equals("date")){

DateFormat df = new SimpleDateFormat("dd.MM.yyyy");

try{log(df.format(obj))}

catch(Exception e){log("LOG.ERROR: Failed date format")}

}

}

}

private log(Object obj){log.debug(obj)}

Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования