Created
December 21, 2021 02:46
-
-
Save anyutianluo/408e88e7a9130025494957f31bc7e2b4 to your computer and use it in GitHub Desktop.
[qry] 分页查询 qryByPage qry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def qryByPageByRobberyPool(Page page, GrailsParameterMap params) { | |
if (!params.max) params.max = page.getPageSize() | |
if (!params.offset) params.offset = page.getStartIndex() | |
if (!params.order) params.order = "desc" | |
if ("repaymentAbility".equals(params.rank)) { | |
params.sort = "repaymentAbility" | |
} else if ("repaymentIntent".equals(params.rank)) { | |
params.sort = "repaymentIntent" | |
} else { | |
params.sort = "objDateCreated" | |
} | |
def criteria = CollectionMediate.createCriteria() | |
def celClosure = { | |
criteria.eq('isMove', false) | |
if (params.repaymentIntent) { | |
criteria.eq('repaymentIntent', params.repaymentIntent) | |
} | |
if (params.repaymentAbility) { | |
criteria.eq('repaymentAbility', params.repaymentAbility) | |
} | |
if (params.isMediate) { | |
criteria.eq('isMediate', params.isMediate) | |
} | |
if (params.phoneRepairStatus) { | |
criteria.eq('phoneRepairStatus', Integer.parseInt(params.phoneRepairStatus)) | |
} | |
if (params.voiceMailToLabelValue) { | |
Boolean voiceMailToLabelValue = params.getBoolean('voiceMailToLabelValue') | |
if (voiceMailToLabelValue != null) { | |
criteria.eq("voiceMailToLabelValue", voiceMailToLabelValue) | |
} | |
} | |
if (params.paymentTokenStatus) { | |
criteria.eq('paymentTokenStatus', params.paymentTokenStatus) | |
} | |
if (params.objName) { | |
criteria.eq('objName', params.objName) | |
} | |
if (params.enterpriseName) { | |
criteria.like("enterpriseName", "%${params.enterpriseName}%") | |
} | |
if (params.enterpriseId) { | |
criteria.eq('enterpriseId', params.enterpriseId) | |
} | |
if (params.objIdNbr) { | |
criteria.eq('objIdNbr', params.objIdNbr) | |
} | |
if (params.orderNo) { | |
criteria.eq('orderNo', params.orderNo) | |
} | |
if (params.tel) { | |
criteria.eq('tel', params.tel) | |
} | |
if (params.authField) { | |
String authField = params.authField | |
criteria.inList('authField', authField.split(",")) | |
} | |
if (StrUtil.isEmpty(params.mediateStatus) || "-1".equals(params.mediateStatus)){ | |
params.mediateStatus = "0,1"; | |
} | |
if (params.mediateStatus) { | |
String para = params.mediateStatus | |
String[] mediateStatus = para.split(",") | |
int[] array = strArrayToIntArray(mediateStatus) | |
criteria.inList('mediateStatus', array) //params.getInt("mediateStatus") | |
} | |
criteria.or { | |
criteria.eq("voiceNotifyStatus",3) | |
criteria.and { | |
criteria.eq("voiceNotifyStatus",2) | |
criteria.eq("haveTask",false) | |
} | |
} | |
// 客户经理 或 法务台席 | |
if (LoginUtils.user.type == 3) { | |
CusterEnterpriseRel custerEnterpriseRel = CusterEnterpriseRel.findByUserId(LoginUtils.userId) | |
if (custerEnterpriseRel) { | |
String enterprises = custerEnterpriseRel.getEnterprises() | |
criteria.inList('enterpriseId', enterprises.split(";")) | |
} else { | |
criteria.eq('enterpriseId', "-1") | |
} | |
} else if (LoginUtils.user.type == 2) { | |
criteria.eq('enterpriseId', LoginUtils.user.enterpriseId) | |
} else if (LoginUtils.user.type == 13) { | |
criteria.eq('enterpriseId', LoginUtils.user.enterpriseId) | |
} | |
//创建时间 | |
if (params.beginDate) { | |
String beginDate = params.get("beginDate").toString().replace("Z", " UTC") | |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z"); | |
def date = format.parse(beginDate) | |
criteria.ge("dateCreated", date) | |
} | |
if (params.endDate) { | |
String endDate = params.get("endDate").toString().replace("Z", " UTC") | |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z"); | |
def date = format.parse(endDate) | |
criteria.le("dateCreated", date) | |
} | |
criteria.eq('isDelete', false) | |
} | |
PagedResultList results = criteria.list(params, celClosure) | |
List<CollectionMediate> list = results.resultList | |
//还款能力字段 | |
List<CollectionMediateVo> vcm = new ArrayList<CollectionMediateVo>() | |
for (CollectionMediate cm : list) { | |
VCollectionObj VcollectionObj = VCollectionObj.findById(cm.getAt("objId")) | |
if (VcollectionObj != null) { | |
CollectionMediateVo collectionMediateVo = new CollectionMediateVo(); | |
BeanUtils.copyProperties(cm.getProperties(), collectionMediateVo) | |
collectionMediateVo.setId(cm.getId()) | |
//添加还款能力字段 | |
def repaymentAbility = repaymentCountService.repaymentAbilityCount(VcollectionObj) | |
def repaymentIntent = repaymentCountService.repaymentIntentCount(VcollectionObj) | |
String Ability = String.valueOf(repaymentAbility) | |
String Intent = String.valueOf(repaymentIntent) | |
collectionMediateVo.setRepaymentAbility(Ability) | |
collectionMediateVo.setRepaymentIntent(Intent) | |
vcm.add(collectionMediateVo) | |
CollectionObj collectionObj = CollectionObj.findByIsDeleteAndId(false,cm.getAt("objId")) | |
if (null != collectionObj){ | |
String dynamicData = collectionObj.getDynamicData(); | |
Map<String, Object> map = JSON.parseObject(dynamicData, LinkedHashMap.class, Feature.OrderedField); | |
String.valueOf(map.get(ExcelService.逾期金额)) | |
collectionMediateVo.setOverdueAmount(String.valueOf(map.get(ExcelService.逾期金额))) | |
} | |
CollectionMediate collectionMediate = CollectionMediate.findByObjId(cm.getAt("objId")) | |
collectionMediate.setRepaymentAbility(Ability) | |
collectionMediate.setRepaymentIntent(Intent) | |
collectionMediate.save() | |
} | |
} | |
page.setTotalCount(results.totalCount) | |
page.setResult(vcm); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment