for (ZpCompanyAuditListVO zpCompanyAuditListVO: pageList.getRecords()) { List<ZpCompanyAuditSchedule> auditScheduleList = zpCompanyAuditScheduleService.list(new LambdaQueryWrapper<ZpCompanyAuditSchedule>() .eq(ZpCompanyAuditSchedule::getCompanyId, zpCompanyAuditListVO.getId()) .orderByDesc(ZpCompanyAuditSchedule::getCreateTime)); zpCompanyAuditListVO.setAuditScheduleList(auditScheduleList); }
时间: 2024-04-19 16:29:10 浏览: 33
这段代码是一个循环,遍历了一个名为`pageList`的列表中的`ZpCompanyAuditListVO`对象。在循环中,根据每个`ZpCompanyAuditListVO`对象的`id`属性,查询并获取相应的`ZpCompanyAuditSchedule`对象列表,并将其赋值给当前的`ZpCompanyAuditListVO`对象的`auditScheduleList`属性。
简而言之,这段代码的作用是为每个`ZpCompanyAuditListVO`对象添加对应的审核进度列表。
相关问题
解释一下这段代码:public R autoSort2(@RequestParam Map<String, Object> params,CaipinxinxiEntity caipinxinxi, HttpServletRequest request){ String userId = request.getSession().getAttribute("userId").toString(); String goodtypeColumn = "caipinfenlei"; List<OrdersEntity> orders = ordersService.selectList(new EntityWrapper<OrdersEntity>().eq("userid", userId).eq("tablename", "caipinxinxi").orderBy("addtime", false)); List<String> goodtypes = new ArrayList<String>(); Integer limit = params.get("limit")==null?10:Integer.parseInt(params.get("limit").toString()); List<CaipinxinxiEntity> caipinxinxiList = new ArrayList<CaipinxinxiEntity>();//去重 List<OrdersEntity> ordersDist = new ArrayList<OrdersEntity>(); for(OrdersEntity o1 : orders) { boolean addFlag = true; for(OrdersEntity o2 : ordersDist) { if(o1.getGoodid()==o2.getGoodid() || o1.getGoodtype().equals(o2.getGoodtype())) { addFlag = false; break; } } if(addFlag) ordersDist.add(o1); } if(ordersDist!=null && ordersDist.size()>0) { for(OrdersEntity o : ordersDist) { caipinxinxiList.addAll(caipinxinxiService.selectList(new EntityWrapper<CaipinxinxiEntity>().eq(goodtypeColumn, o.getGoodtype()))); } } EntityWrapper<CaipinxinxiEntity> ew = new EntityWrapper<CaipinxinxiEntity>(); params.put("sort", "id"); params.put("order", "desc"); //调用caipinxinxi对象的queryPage方法 PageUtils page = caipinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, caipinxinxi), params), params)); List<CaipinxinxiEntity> pageList = (List<CaipinxinxiEntity>)page.getList(); if(caipinxinxiList.size()<limit) { int toAddNum = (limit-caipinxinxiList.size())<=pageList.size()?(limit-caipinxinxiList.size()):pageList.size(); for(CaipinxinxiEntity o1 : pageList) { boolean addFlag = true; for(CaipinxinxiEntity o2 : caipinxinxiList) { if(o1.getId().intValue()==o2.getId().intValue()) { addFlag = false; break; } } if(addFlag) { caipinxinxiList.add(o1); if(--toAddNum==0) break; } } } page.setList(caipinxinxiList); return R.ok().put("data", page); }
, && ordersDist.size()>0) {//判断是不是空集合 for(OrdersEntity o : ordersDist) { String goodTypeValue = DictUtils.getDictLabel(o.getGoodtype(), goodtypeColumn); if(goodTypeValue!=null && !"".equals(goodTypeValue) && !goodtypes.contains(goodTypeValue)) { goodtypes.add(goodTypeValue); } } //根据商品分类查询商品信息 caipinxinxi.setCaipinfenleiList(goodtypes); caipinxinxi.setLimit(limit); caipinxinxiList = caipinxinxiService.selectList(caipinxinxi); } return R.ok().put("data", caipinxinxiList); }
这段代码是一个Java方法,名字为autoSort2,它是一个Controller中的一个方法,作用是根据用户的订单信息进行商品分类并返回相关商品的信息。
该方法有三个参数:params、caipinxinxi和request。其中,params是一个Map类型的参数,用于存储一些请求参数;caipinxinxi是一个实体类,用于封装查询条件;request是一个HttpServletRequest类型的参数,用于获取当前用户的ID。
该方法的执行流程如下:
1.从session中获取当前用户的ID。
2.定义一个String类型的变量goodtypeColumn,用于指定商品分类对应的字典表。
3.根据用户ID从订单表中查询该用户的所有订单,按照下单时间倒序排列,并将结果保存在orders集合中。
4.定义一个空的List集合goodtypes,用于保存所有不重复的商品分类。
5.定义一个整型变量limit,用于指定最多返回的商品数目。
6.定义一个空的List集合caipinxinxiList,用于保存查询到的商品信息,并进行去重处理。
7.定义一个空的List集合ordersDist,用于保存去重后的订单信息。
8.遍历orders集合中的每个订单,判断该订单对应的商品是否已经存在于ordersDist集合中,如果存在则不做处理,否则将该订单添加到ordersDist集合中。
9.遍历ordersDist集合中的每个订单,获取该订单的商品分类,并将其添加到goodtypes集合中(确保不重复)。
10.根据商品分类查询商品信息,并将结果保存到caipinxinxiList集合中。
11.返回caipinxinxiList集合作为查询结果。
@Override public Page<SysUserPolicyEntity> selectInsured(GrpnameForm data, int current, int pageSize) { //查询 String employeeNo = data.getEmployeeNo(); String grpname = data.getGrpname(); List<SysUserPolicyEntity> lcgrpcontVoPage = lcgrpcontMapper.selectInsured(grpname); LambdaQueryWrapper<SysUserPolicyEntity> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ObjectUtils.isNotEmpty(employeeNo), SysUserPolicyEntity::getEmployeeNo, employeeNo); List<SysUserPolicyEntity> sysUserPolicyEntityList = sysUserPolicyMapper.selectList(wrapper); for (SysUserPolicyEntity record : lcgrpcontVoPage) { for (SysUserPolicyEntity policyEntity : sysUserPolicyEntityList) { if (record.getGrpcontno().equals(policyEntity.getGrpcontno())) { record.setSelectFlag(policyEntity.getSelectFlag()); } } } sysUserPolicyMapper.delete(wrapper); Page<SysUserPolicyEntity> objectPage = new Page<>(); objectPage.setRecords(lcgrpcontVoPage); objectPage.setCurrent(current); objectPage.setSize(pageSize); objectPage.setTotal(lcgrpcontVoPage.size()); return objectPage; }自制分页放入数据
可以自己实现分页放入数据,具体代码如下:
```
@Override
public Page<SysUserPolicyEntity> selectInsured(GrpnameForm data, int current, int pageSize) {
//查询
String employeeNo = data.getEmployeeNo();
String grpname = data.getGrpname();
List<SysUserPolicyEntity> lcgrpcontVoPage = lcgrpcontMapper.selectInsured(grpname);
LambdaQueryWrapper<SysUserPolicyEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ObjectUtils.isNotEmpty(employeeNo), SysUserPolicyEntity::getEmployeeNo, employeeNo);
List<SysUserPolicyEntity> sysUserPolicyEntityList = sysUserPolicyMapper.selectList(wrapper);
for (SysUserPolicyEntity record : lcgrpcontVoPage) {
for (SysUserPolicyEntity policyEntity : sysUserPolicyEntityList) {
if (record.getGrpcontno().equals(policyEntity.getGrpcontno())) {
record.setSelectFlag(policyEntity.getSelectFlag());
}
}
}
sysUserPolicyMapper.delete(wrapper);
//自制分页放入数据
int total = lcgrpcontVoPage.size();
int startIndex = (current - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, total);
List<SysUserPolicyEntity> pageList = lcgrpcontVoPage.subList(startIndex, endIndex);
Page<SysUserPolicyEntity> objectPage = new Page<>();
objectPage.setRecords(pageList);
objectPage.setCurrent(current);
objectPage.setSize(pageSize);
objectPage.setTotal(total);
return objectPage;
}
```
其中,total表示总记录数,startIndex表示分页查询的起始位置,endIndex表示分页查询的结束位置,pageList表示分页后的数据。最后返回objectPage即可。
阅读全文