Administrator há 2 anos atrás
pai
commit
80d4a19984

+ 11 - 4
src/main/java/com/sysu/admin/api/crop/ApiCropController.java

@@ -10,6 +10,7 @@ import com.sysu.admin.controller.crop.CropPoint;
 import com.sysu.admin.controller.crop.images.CropImage;
 import com.sysu.admin.controller.crop.images.CropImageService;
 import com.sysu.admin.controller.crop.images.ImageType;
+import com.sysu.admin.controller.geo.land.LandTaskStatus;
 import com.sysu.admin.support.base.BaseComponent;
 import com.sysu.admin.support.shiro.ShiroService;
 import com.sysu.admin.support.system.config.SConfigService;
@@ -19,6 +20,7 @@ import com.xiesx.fastboot.base.result.R;
 import com.xiesx.fastboot.core.token.handle.CurrentToken;
 import com.xiesx.fastboot.utils.CopyUtils;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.ObjectUtils;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.operation.TransformException;
 import org.springframework.beans.BeanUtils;
@@ -40,19 +42,24 @@ public class ApiCropController extends BaseComponent {
     SConfigService mSConfigService;
     @Autowired
     ShiroService mShiroService;
-
     @Autowired
     CropImageService cropImageService;
 
-    static Long testId = 102L;
-
     @RequestMapping("/point_list")
-    public BaseResult pointList(@RequestBody String data) throws FactoryException, TransformException {
+    public BaseResult pointList(@RequestBody String data, @RequestHeader(value = "token",required = false) String token) throws FactoryException, TransformException {
         CropVo vo = JSON.parseObject(data, CropVo.class);
         if(vo.getMeter() > 5000){
             vo.setMeter(5000);
         }
         List<CropPoint> cropPoints = cityLandService.findByBuffer(vo.getPoint(), vo.getMeter());
+        if(ObjectUtils.isNotEmpty(token)){
+            Long userId = Long.valueOf(CurrentToken.getCurrentToken(token).getUserId());
+            for(int i=cropPoints.size() - 1;i > -1;i--){
+                if(cropPoints.get(i).getStatus().intValue() == LandTaskStatus.receive.ordinal() && !cropPoints.get(i).getReceiver().equals(userId)){
+                    cropPoints.remove(i);
+                }
+            }
+        }
         return R.succ(cropPoints);
     }
 

+ 1 - 1
src/main/java/com/sysu/admin/api/user/ApiUserController.java

@@ -43,7 +43,7 @@ public class ApiUserController extends BaseComponent {
      * @return
      */
     @PostMapping("/login")
-    public BaseResult login(@RequestBody String data, @RequestHeader("token") String token) {
+    public BaseResult login(@RequestBody String data, @RequestHeader(value = "token", required = false) String token) {
         SmsReqVo sms = JSON.parseObject(data, SmsReqVo.class);
         if(StringUtils.isNotEmpty(token)){
             return R.succ(getTokenUser(sms.getToken()));

+ 6 - 0
src/main/java/com/sysu/admin/controller/crop/CropPoint.java

@@ -36,6 +36,12 @@ public class CropPoint {
 
     @Column
     private String geojson;
+
+    /**
+     * 领取人
+     */
+    @Column(nullable = false)
+    private Long receiver;
     /**
      * 耕地类型
      */

+ 1 - 1
src/main/java/com/sysu/admin/controller/crop/CropPointRepository.java

@@ -9,7 +9,7 @@ import java.util.List;
 public interface CropPointRepository extends JpaPlusRepository<CropPoint, Long> {
 
 
-    @Query(value = "SELECT id,crop_type,st_asgeojson(center_point) as geojson,status from \"p_crop\" where status in ?3 and St_within(center_point," +
+    @Query(value = "SELECT id,crop_type,st_asgeojson(center_point) as geojson,status,receiver from \"p_crop\" where status in ?3 and St_within(center_point," +
             " ST_Buffer(st_geomfromtext(?1,4326),?2, 'quad_segs=8')" +
             ");",nativeQuery = true)
     List<CropPoint> findByBufferAndStatus(String pointWKT, Double degree, Integer[] status);

+ 3 - 3
src/main/webapp/WEB-INF/jsp/page/crop-image/view.jsp

@@ -19,19 +19,19 @@
                 <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                     <legend>远景</legend>
                 </fieldset>
-                <img src="${fay.url}" width="100%" />
+                <img src="${fay.url}" style="max-width:100%" />
             </div>
             <div>
                 <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                     <legend>中景</legend>
                 </fieldset>
-                <img src="${center.url}" width="100%" />
+                <img src="${center.url}" style="max-width:100%" />
             </div>
             <div>
                 <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                     <legend>近景</legend>
                 </fieldset>
-                <img src="${near.url}" width="100%" />
+                <img src="${near.url}" style="max-width:100%" />
             </div>
         </div>
     </fb:layout>

BIN
src/main/webapp/static/images/status_0.png


BIN
src/main/webapp/static/images/status_1.png


BIN
src/main/webapp/static/images/status_2.png


BIN
src/main/webapp/static/images/status_3.png


+ 4 - 12
src/main/webapp/static/package/style.js

@@ -8,7 +8,6 @@ let globalStyle = {
         });
     },
     pointStyle(f){
-        let colors = ['rgb(88,88,90)','rgb(7,31,250)','rgb(250,189,7)','rgb(7,250,11)']
         let style = new ol.style.Style({
             text: new ol.style.Text({
                 text:f.getId() ? f.getId() : f.get("id"),
@@ -21,17 +20,10 @@ let globalStyle = {
                 }),
                 font:"14px sans-serif"
             }),
-            image: new ol.style.RegularShape({
-                stroke: new ol.style.Stroke({
-                    color: colors[f.get('status')],
-                    width: 1,
-                }),
-                fill: new ol.style.Fill({
-                    color: colors[f.get('status')],
-                }),
-                radius: 15,
-                points:20,
-                angle: 0
+            image: new ol.style.Icon({
+                src:"/static/images/status_"+f.get("status")+".png",
+                scale:0.3,
+                anchor:[0.5,1],
             })
         });
         return style