| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.community.ComMngCarAppletDTO; |
| | | 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.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.ComMngCarDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngStructAreaDO; |
| | | import com.panzhihua.service_community.service.ComMngCarService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | @Resource |
| | | private ComMngCarDAO comMngCarDAO; |
| | | @Resource |
| | | private ComMngStructAreaDAO comMngStructAreaDAO; |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @Override |
| | | public R addComMngCarApplet(ComMngCarAppletDTO comCvtBusinessDTO) { |
| | |
| | | }); |
| | | return R.ok(comMngCarVOS); |
| | | } |
| | | |
| | | @Override |
| | | public R pageQueryComMngCar(PageComMngCarDTO pageComMngCarDTO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = pageComMngCarDTO.getPageNum(); |
| | | Long pageSize = pageComMngCarDTO.getPageSize(); |
| | | if (null == pageNum || 0 == pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null == pageSize || 0 == pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<ComMngCarVO> iPage = comMngCarDAO.pageQueryComMngCar(page, pageComMngCarDTO); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R saveComMngCar(ComMngCarSaveDTO comMngCarSaveDTO) { |
| | | int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>().lambda().eq(ComMngCarDO::getPlateNum, comMngCarSaveDTO.getPlateNum())); |
| | | if (count > 0) { |
| | | return R.ok("车辆已存在"); |
| | | } |
| | | ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectById(comMngCarSaveDTO.getAreaId()); |
| | | if (ObjectUtils.isEmpty(comMngStructAreaDO)) { |
| | | return R.fail("小区不存在"); |
| | | } |
| | | if (ObjectUtils.isEmpty(comMngCarSaveDTO.getMobile())) { |
| | | return R.fail("车主手机号码不能为空"); |
| | | } |
| | | ComMngCarDO comMngCarDO = new ComMngCarDO(); |
| | | BeanUtils.copyProperties(comMngCarSaveDTO, comMngCarDO); |
| | | comMngCarDO.setAreaName(comMngStructAreaDO.getAreaName()); |
| | | comMngCarDO.setCommunityId(comMngStructAreaDO.getCommunityId()); |
| | | comMngCarDO.setCreateAt(new Date()); |
| | | comMngCarDO.setSource(2); |
| | | R<SysUserVO> sysUserVOR = userService.getSysUserVOByPhone(comMngCarSaveDTO.getMobile()); |
| | | if(R.isOk(sysUserVOR)){ |
| | | SysUserVO sysUserVO = JSONObject.parseObject(JSONObject.toJSONString(sysUserVOR.getData()),SysUserVO.class); |
| | | comMngCarSaveDTO.setUserId(sysUserVO.getUserId()); |
| | | } |
| | | if(null!=comMngCarDO.getId() && comMngCarDO.getId()!=0){ |
| | | boolean update = this.updateById(comMngCarDO); |
| | | if (update) { |
| | | return R.ok(); |
| | | } |
| | | }else{ |
| | | boolean insert = this.save(comMngCarDO); |
| | | if (insert) { |
| | | return R.ok(); |
| | | } |
| | | } |
| | | return R.fail(); |
| | | } |
| | | } |