MyTetra Share
Делитесь знаниями!
Анализ по файлу
Время создания: 06.07.2020 12:22
Раздел: INFO - JOB - rtneo - Выгрузки - УПД
Запись: wwwlir/Tetra/master/base/1594009357qs8zodrnzj/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='62d56ab3-e341-a039-9007-ef5a4a399b20'



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.realEstates) from rtneo$Contragent c where c.inn in :listInn and c.user is null order by c.inn')

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

.parameter("listInn" , listInn)

.list()

for(def item : list){

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

}

/**

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

*/

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
Яндекс индекс цитирования