|
|||||||
Скрипт пролонгации
Время создания: 08.04.2020 20:52
Раздел: INFO - JOB - rtneo - Работа над задачами - Пролонгация
Запись: wwwlir/Tetra/master/base/1586350351thtda9q6mz/text.html на raw.githubusercontent.com
|
|||||||
|
|||||||
import java.util.* import com.haulmont.cuba.core.global.* import com.groupstp.rtneo.entity.* import com.groupstp.rtneo.entity.* import com.haulmont.cuba.core.global.*; import com.groupstp.rtneo.service.CompanyService import com.groupstp.rtneo.service.*
def contractService = AppBeans.get(ContractService.NAME) for(def i = 0; i<=910; i++){
List<Contragent> contragents = dataManager.load(Contragent.class) //.query('select distinct c.contragent from rtneo$ContragentRealEstate c where c.contragent.type = 3 and ((c.type.isLiving is null or c.type.isLiving = false) and (c.category.isLiving is null or c.category.isLiving = false)) order by c.contragent.id') .query('select c from rtneo$Contragent c where not c.type = 3 and not c.personalAccount is null') .firstResult(1*i) .maxResults(100) .view("_local") .list();
for(Contragent contragent : contragents){ log.debug(contragent.getPersonalAccount()) def contractsCount = dataManager.loadValue('select count(c) from rtneo$Contract c where c.contragent.id = :id', Integer.class) .parameter("id", contragent.getId()) .optional() .orElse(0)
List<Contract> contracts = [] if(contractsCount == 0){ log.debug("contractsCount is 0") try{ log.debug("create") contracts.addAll(contractService.checkContract(contragent, true)) }catch(Exception e){ log.debug(e) } if(contracts.size() == 0){ log.debug("continue") continue; } }else{ log.debug("contractsCount - ${contractsCount}") }
Contract baseContract = dataManager.load(Contract.class) .query('select c from rtneo$Contract c where c.mainContract is null and c.contragent.id=:contragent order by c.createTs desc') .parameter("contragent", contragent.getId()) .view("_local") .optional() .orElse(null);
if(baseContract != null){ contractService.prolongation(contragent, baseContract); }else{ log.debug("baseContract is null") } } } |
|||||||
Так же в этом разделе:
|
|||||||
|
|||||||
|