| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.house.entity.HouseTenantEntity; |
| | | import org.springblade.modules.house.vo.HouseTenantVO; |
| | | import org.springblade.modules.place.entity.PlaceEntity; |
| | | import org.springblade.modules.place.entity.PlaceExtEntity; |
| | | import org.springblade.modules.place.entity.PlacePractitionerEntity; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 场所详情表 服务实现类 |
| | |
| | | @Autowired |
| | | private IPlacePractitionerService placePractitionerService; |
| | | |
| | | @Autowired |
| | | private IGridService gridService; |
| | | |
| | | /** |
| | | * 自定义查询 |
| | | * @param page |
| | |
| | | */ |
| | | @Override |
| | | public IPage<PlaceExtVO> selectPlaceExtPage(IPage<PlaceExtVO> page, PlaceExtVO placeExt) { |
| | | return page.setRecords(baseMapper.selectPlaceExtPage(page, placeExt)); |
| | | List<String> list = new ArrayList<>(); |
| | | if (null!=placeExt.getRoleName() && !placeExt.getRoleName().equals("")){ |
| | | if (placeExt.getRoleName().equals("网格员")){ |
| | | // 查询对应的房屋地址code |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | if (!placeExt.getRoleName().equals("系统管理员")){ |
| | | placeExt.setCreateUser(AuthUtil.getUserId()); |
| | | } |
| | | } |
| | | return page.setRecords(baseMapper.selectPlaceExtPage(page, placeExt,list)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updatePlaceExt(PlaceExtEntity placeExt) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updatePlaceExt(PlaceExtVO placeExt) { |
| | | // 设置参数 |
| | | placeExt.setUpdateTime(new Date()); |
| | | placeExt.setUpdateUser(AuthUtil.getUserId()); |
| | | // 更新 |
| | | return updateById(placeExt); |
| | | // 更新从业人员信息 |
| | | boolean addFlag = true; |
| | | boolean updateFlag = true; |
| | | boolean removeFlag = true; |
| | | //更新自身 |
| | | boolean update = updateById(placeExt); |
| | | // 查询对应已存在的从业人员 |
| | | QueryWrapper<PlacePractitionerEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("place_id",placeExt.getPlaceId()); |
| | | List<PlacePractitionerEntity> oldList = placePractitionerService.list(wrapper); |
| | | List<PlacePractitionerEntity> list = placeExt.getPlacePractitioner(); |
| | | // 申明新增,修改,删除集合 |
| | | List<PlacePractitionerEntity> newList = new ArrayList<>(); |
| | | List<PlacePractitionerEntity> addList = new ArrayList<>(); |
| | | List<PlacePractitionerEntity> updateList = new ArrayList<>(); |
| | | List<PlacePractitionerEntity> removeList = new ArrayList<>(); |
| | | // 找出需要新增的,否则组成新集合进行比对 |
| | | for (PlacePractitionerEntity practitionerEntity : list) { |
| | | practitionerEntity.setPlaceId(placeExt.getPlaceId()); |
| | | if (null==practitionerEntity.getId()){ |
| | | // 新增 |
| | | PlacePractitionerEntity placePractitionerEntity= new PlacePractitionerEntity(); |
| | | |
| | | placePractitionerEntity.setPlaceId(placeExt.getPlaceId()); |
| | | placePractitionerEntity.setName(practitionerEntity.getName()); |
| | | placePractitionerEntity.setTelephone(practitionerEntity.getTelephone()); |
| | | placePractitionerEntity.setTempAddress(practitionerEntity.getTempAddress()); |
| | | addList.add(placePractitionerEntity); |
| | | }else { |
| | | newList.add(practitionerEntity); |
| | | } |
| | | } |
| | | // 遍历去差集,判断是新增还是删除还是更新 |
| | | // 取旧数据和新提交数据差集--删除 |
| | | removeList = oldList.stream().filter(vo -> !newList.stream().map(e -> |
| | | e.getId()).collect(Collectors.toList()).contains(vo.getId())).collect(Collectors.toList()); |
| | | // 取旧数据和新提交数据交集--更新 |
| | | updateList = newList.stream().filter(vo -> oldList.stream().map(e -> |
| | | e.getId()).collect(Collectors.toList()).contains(vo.getId())).collect(Collectors.toList()); |
| | | |
| | | // 批量新增 |
| | | if (addList.size()>0) { |
| | | addFlag = placePractitionerService.saveBatch(addList); |
| | | } |
| | | // 批量修改 |
| | | if (updateList.size()>0) { |
| | | updateFlag = placePractitionerService.updateBatchById(updateList); |
| | | } |
| | | // 批量删除 |
| | | if (removeList.size()>0) { |
| | | removeFlag = placePractitionerService.removeBatchByIds(removeList); |
| | | } |
| | | // 返回 |
| | | return update && addFlag && updateFlag && removeFlag; |
| | | } |
| | | |
| | | /** |
| | |
| | | taskEntity.setId(placeExt.getTaskId()); |
| | | taskEntity.setStatus(placeExt.getConfirmFlag()); |
| | | taskEntity.setType(1); |
| | | taskEntity.setFrequency(3); |
| | | taskEntity.setName(placeEntity.getPlaceName() + "信息完善任务" + System.currentTimeMillis()); |
| | | taskEntity.setFrequency(1); |
| | | taskEntity.setName(placeEntity.getPlaceName() + "信息完善"); |
| | | // 新增任务 |
| | | boolean save = taskService.save(taskEntity); |
| | | if (save){ |