package com.elephant.framework.galaxy.aroad.module.zhjc.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjh;
import com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhFghjdzb;
import com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGhjhGhjdzb;
import com.elephant.framework.galaxy.aroad.module.zhjc.mapper.ZhjcGhjhFghjdzbMapper;
import com.elephant.framework.galaxy.aroad.module.zhjc.service.ZhjcGhjhFghjdzbService;
import com.elephant.framework.galaxy.aroad.module.zhjc.service.ZhjcGhjhGhjdzbService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.UUID;

/**
 * 智慧决策_规划计划_非规划阶段坐标表
 *
 * @author wangjian
 * @date 2019-05-23 19:00:32
 */
@Service
@AllArgsConstructor
public class ZhjcGhjhFghjdzbServiceImpl extends ServiceImpl<ZhjcGhjhFghjdzbMapper, ZhjcGhjhFghjdzb> implements ZhjcGhjhFghjdzbService {

    final ZhjcGhjhFghjdzbMapper zhjcGhjhFghjdzbMapper;
    final ZhjcGhjhGhjdzbService zhjcGhjhGhjdzbService;

    /**
     * 新增非规划阶段坐标
     * @return
     */
    @Transactional
    public Boolean addFGhjdzb(ZhjcGhjhFghjdzb new_zb) {
        ZhjcGhjhFghjdzb old_zb = zhjcGhjhFghjdzbMapper.selectOne(Wrappers.<ZhjcGhjhFghjdzb>query().lambda().eq(ZhjcGhjhFghjdzb::getXmid,new_zb.getXmid()));
         if (old_zb!=null){
             zhjcGhjhFghjdzbMapper.deleteById(old_zb);
         }
        String shape = zhjcGhjhGhjdzbService.shapeConversion(new_zb.getGeomfeature());
        new_zb.setGeomfeature(shape.substring(1, shape.length()-1));
        int code =zhjcGhjhFghjdzbMapper.insert(new_zb);
        return code>0;
    }
}
