|  | @@ -0,0 +1,53 @@
 | 
	
		
			
				|  |  | +package com.sysu.admin.site.lz;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import com.sysu.admin.controller.lz.area.LzArea;
 | 
	
		
			
				|  |  | +import com.sysu.admin.controller.lz.area.LzAreaService;
 | 
	
		
			
				|  |  | +import com.sysu.admin.controller.lz.clazz.LzClazz;
 | 
	
		
			
				|  |  | +import com.sysu.admin.controller.lz.clazz.LzClazzService;
 | 
	
		
			
				|  |  | +import com.sysu.admin.controller.lz.tree.LzTree;
 | 
	
		
			
				|  |  | +import com.sysu.admin.controller.lz.tree.LzTreeService;
 | 
	
		
			
				|  |  | +import com.sysu.admin.utils.shape.GeoCastUtil;
 | 
	
		
			
				|  |  | +import com.xiesx.fastboot.base.result.BaseResult;
 | 
	
		
			
				|  |  | +import com.xiesx.fastboot.base.result.R;
 | 
	
		
			
				|  |  | +import org.locationtech.jts.geom.MultiPolygon;
 | 
	
		
			
				|  |  | +import org.locationtech.jts.geom.Point;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RequestBody;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@RequestMapping("/site/lz_tree")
 | 
	
		
			
				|  |  | +@RestController
 | 
	
		
			
				|  |  | +public class LzTreeController {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private LzTreeService lzTreeService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private LzAreaService lzAreaService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private LzClazzService lzClazzService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @RequestMapping("/list")
 | 
	
		
			
				|  |  | +    public BaseResult list(){
 | 
	
		
			
				|  |  | +        List<LzTree> list = lzTreeService.findAll();
 | 
	
		
			
				|  |  | +        list.forEach(lzArea -> {
 | 
	
		
			
				|  |  | +            lzArea.setWkt(GeoCastUtil.geomToWkt(lzArea.getPoint()));
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        return R.succ(list);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @RequestMapping("/save")
 | 
	
		
			
				|  |  | +    public BaseResult save(@RequestBody LzTree bean){
 | 
	
		
			
				|  |  | +        bean.setPoint((Point) GeoCastUtil.wktToGeom(bean.getWkt()));
 | 
	
		
			
				|  |  | +        LzArea lzArea = lzAreaService.findByPoint(bean.getWkt());
 | 
	
		
			
				|  |  | +        LzClazz clazz = lzClazzService.findOne(bean.getClazzId());
 | 
	
		
			
				|  |  | +        bean.setClazz(clazz);
 | 
	
		
			
				|  |  | +        bean.setCode(lzArea.getId() + "-"+clazz.getCode() + "-" + bean.getCode());
 | 
	
		
			
				|  |  | +        bean.setLzArea(lzArea);
 | 
	
		
			
				|  |  | +        lzTreeService.save(bean);
 | 
	
		
			
				|  |  | +        return R.succ();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |