|
|||||||
Наименование услуги в дату
Время создания: 09.09.2020 17:11
Раздел: INFO - JOB - rtneo - Работа над задачами - Создание договоров
Запись: wwwlir/Tetra/master/base/1599642688h7cqf5xt60/text.html на raw.githubusercontent.com
|
|||||||
|
|||||||
import java.util.* import com.haulmont.cuba.core.global.* import com.haulmont.cuba.core.entity.*; 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 import java.util.stream.Collectors; import com.groupstp.rtneo.core.bean.tools.* String idEx='f800a60a-9848-a6ff-0bae-59e5103c0b29' List<String> listExInn = inToFile(idEx) 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() .peek{e-> e[0] = getDate(e[0]).toString()} // .map{e->e[0]} .collect(Collectors.toList()) } public Date getDate(String str){ def df = new SimpleDateFormat("dd-MM-yyyy") def monthes = ['01':'январь','02':'февраль','03':'март','04':'апрель','05':'май','06':'июня','07':'июль','08':'август','09':'сентябрь','10':'октябрь','11':'ноябрь','12':'декабрь'] def years = ['2019', '2020'] def month = monthes.entrySet().stream().filter{e-> str.toLowerCase().contains(e.getValue())}.findFirst().orElse(null) def year = years.stream().filter{e-> str.contains(e)}.findFirst().orElse(null) if(month == null || year == null)return null Date date = df.parse("01-${month.getKey()}-${year}") // _("${str} = ${month} - ${year} >> ${date}") return date } /** * Логирование */ 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)} |
|||||||
Так же в этом разделе:
|
|||||||
|
|||||||
|