| | |
| | | import com.xiaopeng.api.model.map.XpGeoFencingPolygon; |
| | | import com.xiaopeng.api.model.operation.*; |
| | | import com.xiaopeng.api.query.operation.XpStationQuery; |
| | | import com.xiaopeng.api.vo.account.LoginUser; |
| | | import com.xiaopeng.api.vo.operation.XpStationVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | import com.xiaopeng.map.constant.I18nKeyConstant; |
| | | import com.xiaopeng.map.mapper.XpRegionMapper; |
| | | import com.xiaopeng.map.mapper.XpStationMapper; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public class XpStationServiceImpl extends ServiceImpl<XpStationMapper, XpStation> implements XpStationService { |
| | | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | |
| | | ); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | public static String getPinyinInitials(String chinese) { |
| | | StringBuilder pinyinInitials = new StringBuilder(); |
| | |
| | | |
| | | this.updateById(dto); |
| | | |
| | | save_operatingArea(dto); |
| | | |
| | | savePoint(dto); |
| | | |
| | | saveMongo_operatingArea(dto); |
| | | |
| | | |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | log.error("新增场站失败", e); |
| | |
| | | try { |
| | | // dto.setStatus(0); //status = 场站状态 0=草稿 1=待测试 2=测试中 3=测试不通过 4=可运营 5=待生效 6=启用中 7=已停用 8=失效 |
| | | this.updateById(dto); |
| | | // 删除旧的区域数据,然后保存新的区域数据 |
| | | remove_operatingArea(dto); |
| | | save_operatingArea(dto); |
| | | xpPointService.clearStationInfoByStationId(dto.getId()); |
| | | savePoint(dto); |
| | | // 删除旧的区域数据,然后保存新的区域数据 |
| | | removeMongo_operatingArea(dto); |
| | | saveMongo_operatingArea(dto); |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | log.error("新增场站失败", e); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 场站 失效-围栏失效 场站失效 |
| | | * @param electronicId |
| | | */ |
| | | @Override |
| | | public void setStatusFailure(Long electronicId){ |
| | | LambdaQueryWrapper<XpStation> query = new LambdaQueryWrapper<>(); |
| | | query.eq(XpStation::getElectronicId, electronicId); |
| | | query.eq(XpStation::getDeleted, 0); |
| | | |
| | | List<XpStation> list = this.list(query); |
| | | if(!list.isEmpty()){ |
| | | for (XpStation xpStation : list) { |
| | | this.setStatus(xpStation,4); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean setStatus(XpStation bean, Integer status){ |
| | | |
| | | bean.setStatus(status); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | bean.setUpdateBy(loginUser.getUsername()); |
| | | bean.setUpdateTime(LocalDateTime.now()); |
| | | bean.setStatus(status);//场站状态 0=草稿 1=待启用 2=启用中 3=已停用 4=失效 |
| | | boolean b = updateById(bean); |
| | | if(b){ |
| | | //场站状态 0=草稿 1=待测试 2=测试中 3=测试不通过 4=可运营 5=待生效 6=启用中 7=已停用 8=失效 |
| | | List<Integer> statusList = Arrays.asList(4, 5, 6, 7) ; |
| | | if(statusList.contains(status) ){ |
| | | save_operatingArea(bean); |
| | | } |
| | | if(status == 7 ){ |
| | | remove_operatingArea(bean); |
| | | if(status == 2){ |
| | | saveMongo_operatingArea(bean); |
| | | }else if(status == 3 || status == 4){ |
| | | removeMongo_operatingArea(bean); |
| | | } |
| | | } |
| | | return b; |
| | | } |
| | | |
| | | private void remove_operatingArea(XpStation bean) { |
| | | private void removeMongo_operatingArea(XpStation bean) { |
| | | // 同步删除Mongo电子围栏多边形 |
| | | Query delMongoQuery = new Query(); |
| | | delMongoQuery.addCriteria(Criteria.where("stationId").is(String.valueOf(bean.getId()))); |
| | | mongoTemplate.remove(delMongoQuery, XpGeoFencingPolygon.class); |
| | | } |
| | | |
| | | private void save_operatingArea (XpStation bean) { |
| | | XpGeoFencingPolygon xpGeoFencingPolygon = new XpGeoFencingPolygon(); |
| | | xpGeoFencingPolygon.setFenceId(String.valueOf(bean.getElectronicId())); |
| | | xpGeoFencingPolygon.setName(bean.getStationName()); |
| | | xpGeoFencingPolygon.setAreaId(String.valueOf(bean.getElectronicAreaId())); |
| | | xpGeoFencingPolygon.setCityCode(bean.getCityCode()); |
| | | xpGeoFencingPolygon.setStationId(String.valueOf(bean.getId())); |
| | | xpGeoFencingPolygon.setOperationStrategy(null);//运营策略 |
| | | // 将围栏点转换为GeoJSON多边形 |
| | | GeoJsonPolygon geoJsonPolygon = xpElectronicFenceService.convertToGeoJsonPolygon(bean.getFencePoints()); |
| | | xpGeoFencingPolygon.setPoints(geoJsonPolygon); |
| | | mongoTemplate.insert(xpGeoFencingPolygon); |
| | | private void saveMongo_operatingArea (XpStation bean) { |
| | | |
| | | //场站状态 0=草稿 1=待启用 2=启用中 3=已停用 4=失效 |
| | | if(bean.getStatus() == 2){ |
| | | XpGeoFencingPolygon xpGeoFencingPolygon = new XpGeoFencingPolygon(); |
| | | xpGeoFencingPolygon.setFenceId(String.valueOf(bean.getElectronicId())); |
| | | xpGeoFencingPolygon.setName(bean.getStationName()); |
| | | xpGeoFencingPolygon.setAreaId(String.valueOf(bean.getElectronicAreaId())); |
| | | xpGeoFencingPolygon.setCityCode(bean.getCityCode()); |
| | | xpGeoFencingPolygon.setStationId(String.valueOf(bean.getId())); |
| | | xpGeoFencingPolygon.setOperationStrategy(null);//运营策略 |
| | | // 将围栏点转换为GeoJSON多边形 |
| | | GeoJsonPolygon geoJsonPolygon = xpElectronicFenceService.convertToGeoJsonPolygon(bean.getFencePoints()); |
| | | xpGeoFencingPolygon.setPoints(geoJsonPolygon); |
| | | mongoTemplate.insert(xpGeoFencingPolygon); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 启用操作 |
| | | * @param bean |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateStatusEnable(XpStation bean){ |
| | | |
| | | xpPointService.statusEnableByStationId(bean.getId()); |
| | | return setStatus(bean, 2); |
| | | } |
| | | |
| | | /** |
| | | * 停用 |
| | |
| | | public boolean updateStatusStop(XpStation bean, Boolean pointStop){ |
| | | |
| | | xpPointService.statusStopByStationId(bean.getId(),pointStop); |
| | | return setStatus(bean, 7); |
| | | return setStatus(bean, 3); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public boolean removeById(XpStation bean, Boolean pointDelete){ |
| | | boolean b = true; |
| | | //场站状态 0=草稿 1=待测试 2=测试中 3=测试不通过 4=可运营 5=待生效 6=启用中 7=已停用 8=失效 |
| | | if(bean.getStatus() == 1 || bean.getStatus() == 2 || bean.getStatus() == 3 || bean.getStatus() == 7 || bean.getStatus() == 8){ |
| | | //场站状态 0=草稿 1=待启用 2=启用中 3=已停用 4=失效 |
| | | if(bean.getStatus() != 2){ |
| | | b = super.removeById(bean.getId()); |
| | | } |
| | | if(bean.getStatus() == 7 || bean.getStatus() == 8){ |
| | | xpPointService.pointDeleteByStationId(bean.getId(),pointDelete); |
| | | } |
| | | if(b){ |
| | | // 同步删除Mongo电子围栏多边形 |
| | | Query delMongoQuery = new Query(); |
| | | delMongoQuery.addCriteria(Criteria.where("stationId").is(String.valueOf(bean.getId()))); |
| | | mongoTemplate.remove(delMongoQuery, XpGeoFencingPolygon.class); |
| | | xpPointService.pointDeleteByStationId(bean.getId(),pointDelete); |
| | | if(b){ |
| | | // 同步删除Mongo电子围栏多边形 |
| | | Query delMongoQuery = new Query(); |
| | | delMongoQuery.addCriteria(Criteria.where("stationId").is(String.valueOf(bean.getId()))); |
| | | mongoTemplate.remove(delMongoQuery, XpGeoFencingPolygon.class); |
| | | } |
| | | } |
| | | return b; |
| | | |