| | |
| | | import com.panzhihua.common.model.dtos.community.ComMngCarSaveDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComMngCarDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngCarExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngCarVO; |
| | | import com.panzhihua.common.model.vos.user.SysUserVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.service_community.dao.ComMngCarDAO; |
| | | import com.panzhihua.service_community.dao.ComMngStructAreaDAO; |
| | | import com.panzhihua.service_community.model.dos.ComCvtServeDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngCarDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngStructAreaDO; |
| | | import com.panzhihua.service_community.service.ComMngCarService; |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @description: |
| | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | |
| | | @Override |
| | | public R addComMngCarApplet(ComMngCarAppletDTO comCvtBusinessDTO) { |
| | | int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>().lambda().eq(ComMngCarDO::getPlateNum, comCvtBusinessDTO.getPlateNum())); |
| | | int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>().lambda() |
| | | .eq(ComMngCarDO::getPlateNum, comCvtBusinessDTO.getPlateNum()) |
| | | .and(wrapper->wrapper.eq(ComMngCarDO::getSource,1))); |
| | | if (count > 0) { |
| | | return R.ok("车辆已存在"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public R saveComMngCar(ComMngCarSaveDTO comMngCarSaveDTO) { |
| | | int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>().lambda().eq(ComMngCarDO::getPlateNum, comMngCarSaveDTO.getPlateNum())); |
| | | if (count > 0) { |
| | | ComMngCarDO exist= comMngCarDAO.selectOne(new QueryWrapper<ComMngCarDO>() |
| | | .lambda().eq(ComMngCarDO::getPlateNum, comMngCarSaveDTO.getPlateNum()).and(wrapper->wrapper.eq(ComMngCarDO::getSource,2))); |
| | | /*if (comMngCarSaveDTO.getId()!=0 && exist.getId()!=comMngCarSaveDTO.getId()) { |
| | | return R.ok("车辆已存在"); |
| | | } |
| | | }*/ |
| | | ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectById(comMngCarSaveDTO.getAreaId()); |
| | | if (ObjectUtils.isEmpty(comMngStructAreaDO)) { |
| | | return R.fail("小区不存在"); |
| | |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R deleteComMngCar(Long id) { |
| | | int delete = comMngCarDAO.deleteById(id); |
| | | if (delete==0) { |
| | | return R.fail("车辆信息不存在"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R listSaveMngCarExcelVO(List<ComMngCarExcelVO> list, Long communityId) { |
| | | //获取社区下所有的小区 |
| | | List<ComMngStructAreaDO> comMngStructAreaDOs = comMngStructAreaDAO.selectList(new QueryWrapper<ComMngStructAreaDO>().lambda().eq(ComMngStructAreaDO::getCommunityId,communityId)); |
| | | Map<String,ComMngStructAreaDO> areaMap = new HashMap<>(comMngStructAreaDOs.size()); |
| | | comMngStructAreaDOs.forEach(comMngStructAreaDO->{ |
| | | areaMap.put(comMngStructAreaDO.getAreaName(),comMngStructAreaDO); |
| | | }); |
| | | List<ComMngCarDO> comMngCarDOS = new ArrayList<>(); |
| | | list.forEach(vo->{ |
| | | int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>() |
| | | .lambda().eq(ComMngCarDO::getPlateNum, vo.getPlateNum()).and(wrapper->wrapper.eq(ComMngCarDO::getSource,2))); |
| | | if(count==0 && areaMap.containsKey(vo.getAreaName())){ |
| | | ComMngCarDO comMngCarDO = new ComMngCarDO(); |
| | | BeanUtils.copyProperties(vo,comMngCarDO); |
| | | comMngCarDO.setCommunityId(communityId); |
| | | comMngCarDO.setAreaId(areaMap.get(vo.getAreaName()).getId()); |
| | | R<SysUserVO> sysUserVOR = userService.getSysUserVOByPhone(vo.getMobile()); |
| | | if(R.isOk(sysUserVOR)){ |
| | | SysUserVO sysUserVO = JSONObject.parseObject(JSONObject.toJSONString(sysUserVOR.getData()),SysUserVO.class); |
| | | comMngCarDO.setUserId(sysUserVO.getUserId()); |
| | | } |
| | | comMngCarDO.setSource(2); |
| | | comMngCarDOS.add(comMngCarDO); |
| | | } |
| | | }); |
| | | this.saveBatch(comMngCarDOS); |
| | | return R.ok("共计导入车辆数量:"+comMngCarDOS.size()); |
| | | } |
| | | } |