MyTetra Share
Делитесь знаниями!
files/groovyscripts/updateMunicipalityForRealEstate.groovy
Время создания: 09.12.2019 13:35
Раздел: INFO - JOB - CUBA - GroovyScripts
Запись: wwwlir/Tetra/master/base/15758697276zrtucjcba/text.html на raw.githubusercontent.com

import com.groupstp.rtneo.entity.*

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


DataManager dataManager = AppBeans.get(DataManager.NAME)


ViewRepository vRep = AppBeans.get(ViewRepository.NAME)


View realEstateView = vRep.getView(RealEstate.class, '_base');

realEstateView.addProperty("contragents");


View contragentRealEstateView = vRep.getView(ContragentRealEstate.class, '_base');

contragentRealEstateView.addProperty("contragent");

contragentRealEstateView.addProperty("livingArea");


def startDate = Date.parse( 'yyyy-MM-dd', '2019-11-10')


def reList = dataManager.load(RealEstate.class)

.query('select distinct re from rtneo$RealEstate re join re.contragents c where c.createTs >:dateStart and c.createdBy like \'%dataminer%\' and c.contragent.name like \'%ИРКУТСКАЯ ОБЛАСТНАЯ ИНФЕКЦИОННАЯ КЛИНИЧЕСКАЯ БОЛЬНИЦА%\' order by re.cadastralNumber, re.createTs asc')

.parameter('dateStart', startDate)

.view(realEstateView)

.list()


log.debug('Всего ' + reList.size() + ' объектов')


for(def re:reList)

{

def creInRe = re.contragents

def previousName = null

def previousLivingArea = null

def previousINN = null

log.debug('re: ' + re.cadastralNumber + ', всего creInRe: ' + creInRe.size())

for(def cre:creInRe)

{

def reloadedCRE = null

try

{


reloadedCRE = dataManager.load(ContragentRealEstate.class)

.id(cre.id)

.view(contragentRealEstateView)

.one()

}

catch (e)

{}

if(reloadedCRE != null)

{

def contragent = reloadedCRE.contragent

log.debug('re: ' + re.cadastralNumber + ', cre: ' + reloadedCRE.id + ', ' + contragent.name)

log.debug(">> ${contragent.name}=${previousName} AND ${reloadedCRE.livingArea}=${previousLivingArea} AND ${contragent.inn}=${previousINN} <<")

if(contragent.name.equals(previousName) && reloadedCRE.livingArea == previousLivingArea && contragent.inn == previousINN)

{

//log.debug('будет удален contragent: ' + contragent.id + ', ' + contragent.name + ', cre ' + reloadedCRE.id)

try

{

//dataManager.remove(contragent)

log.debug('удален contragent: ' + contragent.id + ', ' + contragent.name + ', cre ' + reloadedCRE.id)

}

catch(def ex)

{

log.debug('не удалось удалить contragent: ' + contragent.id + ', ' + contragent.name)

}

}

previousName = contragent.name

previousLivingArea = reloadedCRE.livingArea

previousINN = contragent.inn

}

}

}

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