|
|||||||
Создание исправления
Время создания: 26.08.2020 14:16
Раздел: INFO - JOB - rtneo - Работа над задачами - Исправительные начисления
Запись: wwwlir/Tetra/master/base/1598422569iiz4snh5nu/text.html на raw.githubusercontent.com
|
|||||||
|
|||||||
import com.groupstp.rtneo.entity.*; import com.haulmont.cuba.core.entity.*; import com.haulmont.cuba.core.global.*; import com.groupstp.rtneo.service.*; import com.groupstp.rtneo.core.bean.* import java.text.SimpleDateFormat def service = AppBeans.get(CalculationWorker.NAME) SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy") long st = System.currentTimeMillis(); String idEx='088710b5-6554-c2ca-22ac-f6f39163a3cc' List<String> listExInn = inToFile(idEx) _(listExInn.size()) String q = 'select a.contragent, a.contractPosition.contract.id, a.contractPosition.contract, min(a.period), max(a.period) from rtneo$Accrual a where a.contragent.inn in :innList and a.price = 594.52800 group by a.contragent, a.contractPosition.contract.id' List<KeyValueEntity> contracts = dataManager.loadValues(q) .properties("contragent", "id", "contract", "start", "end") .parameter("innList", listExInn) // .maxResults(100) .list(); Date fromDate = format.parse("01.07.2019") Date beforeDate = format.parse("31.12.2019") Date currentDate = format.parse("30.06.2019") for(def item : contracts){ _("${item.getValue('contragent')}, ${item.getValue('contract')}, ${item.getValue('start')}, ${item.getValue('end')}") service.calculateAccrualsCorr(fromDate, beforeDate, item.getValue('contragent'), currentDate, item.getValue('contract'), 1); // listAccrual.each{_(it)} } _(">> Contragents load = ${System.currentTimeMillis()-st}") /** ******************************************************************************** */ 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 com.opencsv.CSVReader; import org.apache.commons.collections.CollectionUtils import java.util.stream.Collectors; List<String> inToFile(String id){ FileDescriptor fd = dataManager.load(FileDescriptor.class) .id(UuidProvider.fromString(id)) .view(View.MINIMAL) .optional().orElse(null);
if(fd == null){throw new RuntimeException("fileNotFound")}
FileStorageAPI fileStorageAPI=AppBeans.get(FileStorageAPI.NAME); InputStream inputStream=fileStorageAPI.openStream(fd) CSVReader reader = new CSVReader(new InputStreamReader(inputStream, "UTF-8"));
return reader.readAll().stream() .map{e->e[0]}.collect(Collectors.toList()) } /** * Логирование */ 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)} |
|||||||
Так же в этом разделе:
|
|||||||
|
|||||||
|