|
|||||||
Дубли 2
Время создания: 11.12.2019 14:06
Раздел: INFO - JOB - CUBA - GroovyScripts
Запись: wwwlir/Tetra/master/base/1576044377yg141gded8/text.html на raw.githubusercontent.com
|
|||||||
|
|||||||
import com.groupstp.rtneo.entity.* import com.haulmont.cuba.core.global.* import com.haulmont.cuba.core.global.ViewRepository; import com.haulmont.cuba.core.global.View; import com.groupstp.rtneo.core.bean.ContragentWorker; DataManager dataManager = AppBeans.get(DataManager.NAME) ViewRepository vRep = AppBeans.get(ViewRepository.NAME) View viewCre = vRep.getView(ContragentRealEstate.class, "_minimal") viewCre.addProperty("realEstate", vRep.getView(RealEstate.class, "_minimal").addProperty("cadastralNumber")) viewCre.addProperty("contragent", vRep.getView(Contragent.class, "_minimal")) viewCre.addProperty("calculationAmount") viewCre.addProperty("livingArea") View viewContragent = vRep.getView(Contragent.class, "_minimal") viewContragent.addProperty("inn") viewContragent.addProperty("personalAccount") viewContragent.addProperty("type") def createPA = 0 def changeContragent = 0 def deleteContragent = 0 def i = 0 def contragents = dataManager.load(Contragent.class) .query('select c from rtneo$Contragent c where c.personalAccount is null and c.createdBy like \'%dataminer%\' order by c.inn') .firstResult(i*10) .maxResults(10) .view(viewContragent) .list(); def previousINN = null def previousName = null for(Contragent contragent : contragents){ log.debug("\n*****************************************************************") log.debug("contragent - ${contragent} is inn - ${contragent.getInn()}") //log.debug(dataManager.loadValue('select count(c) from rtneo$Contragent c where c.inn = :inn', Integer.class).parameter("inn", contragent.getInn()).optional().orElse(0)) if(contragent.getInn() == null){ log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...${contragent.getType()}") if(contragent.getType() == ContragentType.PERSONAL){ log.debug("++++++++++++++++++++++++=${contragent.getType()}") log.debug("Нужно сгенерировать ЛС -- (${contragent.getName()})") contragent.setPersonalAccount(generatePersonalNumber(contragent)) log.debug("ЛС -- (${contragent.getPersonalAccount()})") createPA++ dataManager.commit(contragent) continue } } // if(previousINN == contragent.getInn()){ // log.debug("DELETE ${contragent.getId()}") // log.debug("[[[[[[[[[[[[[[[[CONTINUE ${contragent.getInn()}]]]]]]]]]]]]]]]]]]") // continue // } // previousINN = contragent.getInn()
log.debug(">>SEARCH CONTRAGENT!<<") def paContragent = dataManager.load(Contragent.class) .query('select c from rtneo$Contragent c where c.inn = :inn and not c.personalAccount is null') .parameter("inn", contragent.getInn()) .view(viewContragent) .optional() .orElse(null) log.debug("paContragent - ${paContragent}")
if(paContragent == null){ log.debug("Нужно сгенерировать ЛС -- (${contragent.getName()})") contragent.setPersonalAccount(generatePersonalNumber(contragent)) createPA++ dataManager.commit(contragent) continue }else{ log.debug("===================paContragent found ===================") }
// def paCres = paContragent.getRealEstates() def paCres = dataManager.load(ContragentRealEstate.class) .query('select c from rtneo$ContragentRealEstate c where c.contragent.id = :id') .parameter("id", paContragent.getId()) .view(viewCre) .list() log.debug("paCres.size() - ${paCres.size()}")
// def cres = contragent.getRealEstates() def cres = dataManager.load(ContragentRealEstate.class) .query('select c from rtneo$ContragentRealEstate c where c.contragent.id = :id') .parameter("id", contragent.getId()) .view(viewCre) .list() log.debug("cres.size() - ${cres.size()}")
log.debug(">>SEARCH CRE<<") for(ContragentRealEstate cre : cres){
def found = false for(ContragentRealEstate paCre : paCres){
log.debug("${paCre.getRealEstate().getCadastralNumber()}")
if(paCre.getRealEstate().getCadastralNumber() == cre.getRealEstate().getCadastralNumber()){ if(paCre.getCalculationAmount() == cre.getLivingArea() || paCre.getLivingArea() == cre.getLivingArea()){ found = true break } }
}
if(found){ log.debug("found cad - ${cre.getRealEstate().getCadastralNumber()}") }else{ log.debug("no found cad - ${cre.getRealEstate().getCadastralNumber()} need to create!!!") if(cre.getCalculationAmount() == 0 || cre.getCalculationAmount() == null) cre.setCalculationAmount(cre.getLivingArea()) cre.setContragent(paContragent) dataManager.commit(cre) changeContragent++ }
}
log.debug("DELETE ${contragent.getId()}") dataManager.remove(contragent) deleteContragent++ } log.debug("Create PA = ${createPA}, changeCREContragent = ${changeContragent}, deleteContragent = ${deleteContragent}") def generatePersonalNumber(Contragent contragent){ ContragentWorker сontragentWorker = AppBeans.get(ContragentWorker.NAME) return сontragentWorker.createAccountNumber(contragent) } |
|||||||
Так же в этом разделе:
|
|||||||
|
|||||||
|