Просмотр исходного кода

修复首页地图地块列表未返回负责人姓名和联系方式的bug

liuyaowen 10 месяцев назад
Родитель
Сommit
cbea3cc135

+ 34 - 19
src/main/java/com/yunfeiyun/agmp/fms/controller/FmsBlockController.java

@@ -4,6 +4,7 @@ import com.yunfeiyun.agmp.common.annotation.Log;
 import com.yunfeiyun.agmp.common.constant.ResConstants;
 import com.yunfeiyun.agmp.common.core.controller.BaseController;
 import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
+import com.yunfeiyun.agmp.common.core.domain.entity.SysUser;
 import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
 import com.yunfeiyun.agmp.common.enums.BusinessType;
 import com.yunfeiyun.agmp.common.enums.CommonEnums;
@@ -11,6 +12,7 @@ import com.yunfeiyun.agmp.common.framework.manager.ResManager;
 import com.yunfeiyun.agmp.common.utils.SecurityUtils;
 import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
 import com.yunfeiyun.agmp.common.web.system.domain.SysRes;
+import com.yunfeiyun.agmp.common.web.system.mapper.SysUserMapper;
 import com.yunfeiyun.agmp.fms.domain.FmsBlock;
 import com.yunfeiyun.agmp.fms.domain.FmsLand;
 import com.yunfeiyun.agmp.fms.domain.reqvo.FmsBlockBindUserReqVo;
@@ -29,6 +31,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.util.*;
@@ -42,8 +45,7 @@ import java.util.stream.Collectors;
  */
 @RestController
 @RequestMapping("/fms/block")
-public class FmsBlockController extends BaseController
-{
+public class FmsBlockController extends BaseController {
     @Autowired
     private IFmsBlockService fmsBlockService;
     @Autowired
@@ -56,7 +58,8 @@ public class FmsBlockController extends BaseController
     private ResManager resManager;
     @Autowired
     private DataAuthUtil dataAuthUtil;
-
+    @Resource
+    private SysUserMapper sysUserMapper;
 
     /**
      * 查询地块列表
@@ -149,7 +152,7 @@ public class FmsBlockController extends BaseController
         if (b) {
             //true需要进行权限校验。下拉框基地列表查询需要包含分配的基地以及分配地块所属基地
             List<String> strings = dataAuthUtil.blockList();
-            if (strings.size() == 0) {
+            if (strings.isEmpty()) {
                 return getDataTable(new ArrayList<>());
             }
             reqVo.setDataFilter(true);
@@ -171,7 +174,7 @@ public class FmsBlockController extends BaseController
     public void export(HttpServletResponse response,@RequestBody FmsBlock fmsBlock) {
         fmsBlock.setTid(SecurityUtils.getTid());
         List<FmsBlock> list = fmsBlockService.selectFmsBlockList(fmsBlock);
-        ExcelUtil<FmsBlock> util = new ExcelUtil<FmsBlock>(FmsBlock.class);
+        ExcelUtil<FmsBlock> util = new ExcelUtil<>(FmsBlock.class);
         util.exportExcel(response, list, "地块数据");
     }
 
@@ -230,32 +233,28 @@ public class FmsBlockController extends BaseController
         blockQuery.setLandId(landId);
         List<FmsBlock> fmsBlocks = fmsBlockService.selectFmsBlockList(blockQuery);
         // 初始化辅助查询集合
-        Map<String, FmsBlockPlanResVo> fmsBlockPlanResVoMap = new HashMap<>();
         blockIds = new ArrayList<>();
+        List<String> userIds = new ArrayList<>();
         for(FmsBlock fmsBlock : fmsBlocks){
-            FmsBlockPlanResVo fmsBlockPlanResVo = new FmsBlockPlanResVo();
-            fmsBlockPlanResVo.setFmsPlanCropResVoList(new ArrayList<>());
-            BeanUtils.copyProperties(fmsBlock,fmsBlockPlanResVo);
-            fmsBlockPlanResVoMap.put(fmsBlockPlanResVo.getBlockId(),fmsBlockPlanResVo);
             blockIds.add(fmsBlock.getBlockId());
+            userIds.add(fmsBlock.getBlockManager());
         }
+        List<SysUser> sysUserList = sysUserMapper.selectUserListByUserIds(userIds);
+        Map<String,SysUser> userMap = sysUserList.stream().collect(Collectors.toMap(SysUser::getUserId,item->item));
         // 查询地块种植计划
         FmsPlanReqVo fmsPlanQuery = new FmsPlanReqVo();
         fmsPlanQuery.setBlockIds(blockIds);
         fmsPlanQuery.setTid(SecurityUtils.getTid());
         fmsPlanQuery.setPlanStatusArray(Arrays.asList(CommonEnums.PLAN_STATUS_START.getCode(), CommonEnums.PLAN_STATUS_NOT_START.getCode()));
         List<FmsPlanCropResVo> fmsPlanCropResVoList = fmsPlanService.selectFmsCropPlanResVoList(fmsPlanQuery);
-        Map<String,FmsPlanCropResVo> cropMap = new HashMap<>();
-        // 填充返回数据
+        Map<String,FmsPlanCropResVo> blockPlanMap = new HashMap<>();
+        List<String> cropIds = new ArrayList<>();
         for(FmsPlanCropResVo fmsPlanCropResVo : fmsPlanCropResVoList){
-            cropMap.put(fmsPlanCropResVo.getCropId(),fmsPlanCropResVo);
-            FmsBlockPlanResVo fmsBlockPlanResVo = fmsBlockPlanResVoMap.get(fmsPlanCropResVo.getBlockId());
-            if(null != fmsBlockPlanResVo){
-                fmsBlockPlanResVo.getFmsPlanCropResVoList().add(fmsPlanCropResVo);
-            }
+            cropIds.add(fmsPlanCropResVo.getCropId());
+            blockPlanMap.put(fmsPlanCropResVo.getBlockId(),fmsPlanCropResVo);
         }
         // 查询作物图片
-        List<SysRes> sysResList = resManager.queryRes(new ArrayList<>(cropMap.keySet()), ResConstants.BizType.CROP.getKey());
+        List<SysRes> sysResList = resManager.queryRes(new ArrayList<>(cropIds), ResConstants.BizType.CROP.getKey());
         Map<String,SysRes> resMap = sysResList.stream().collect(Collectors.toMap(SysRes::getResBusId,item->item));
         for(FmsPlanCropResVo fmsPlanCropResVo :fmsPlanCropResVoList){
             SysRes sysRes = resMap.get(fmsPlanCropResVo.getCropId());
@@ -263,6 +262,22 @@ public class FmsBlockController extends BaseController
                 fmsPlanCropResVo.setCropPreview(sysRes.getResOssUrl());
             }
         }
-        return AjaxResult.success(fmsBlockPlanResVoMap.values());
+        List<FmsBlockPlanResVo> list = new ArrayList<>();
+        for(FmsBlock fmsBlock : fmsBlocks){
+            FmsBlockPlanResVo fmsBlockPlanResVo = new FmsBlockPlanResVo();
+            BeanUtils.copyProperties(fmsBlock,fmsBlockPlanResVo);
+            fmsBlockPlanResVo.setFmsPlanCropResVoList(new ArrayList<>());
+            SysUser sysUser = userMap.get(fmsBlock.getBlockManager());
+            if(null != sysUser){
+                fmsBlockPlanResVo.setBlockManagername(sysUser.getUserName());
+            }
+            FmsPlanCropResVo fmsPlanCropResVo = blockPlanMap.get(fmsBlock.getBlockId());
+            if(null != fmsPlanCropResVo){
+                fmsBlockPlanResVo.getFmsPlanCropResVoList().add(fmsPlanCropResVo);
+            }
+            list.add(fmsBlockPlanResVo);
+        }
+
+        return AjaxResult.success(list);
     }
 }

+ 2 - 0
src/main/java/com/yunfeiyun/agmp/fms/domain/FmsBlock.java

@@ -90,6 +90,8 @@ public class FmsBlock extends BaseEntity
     private String blockTransferinfo;
     @Excel(name = "土地所有人信息")
     private String blockOwnerinfo;
+    @Excel(name = "地块联系方式")
+    private String blockTel;
 
     /**序号*/
     private Integer blockSeq;

+ 1 - 0
src/main/java/com/yunfeiyun/agmp/fms/domain/resvo/FmsBlockResVo.java

@@ -84,6 +84,7 @@ public class FmsBlockResVo extends BaseEntity
     private String cropPreviews;
     /**地块图标*/
     private String blockIcon;
+    private String blockTel;
 
     public String getBlockTypeContent() {
         if (!StringUtils.isEmpty(this.blockType)) {

+ 3 - 3
src/main/resources/mapper/FmsBlockMapper.xml

@@ -10,7 +10,7 @@
     </sql>
 
     <sql id="selectFmsBlockHasResVo">
-        select b.blockId, b.landId, b.blockName, b.blockType, b.blockManager, b.blockManagername, b.blockArea, b.blockSeq, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon, b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,
+        select b.blockId, b.landId, b.blockName, b.blockType, b.blockManager, b.blockManagername, b.blockArea, b.blockSeq, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon, b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,blockTel,
         (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = b.blockId) blockPreview,
         (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = b.blockId) resIds,
         b.tid
@@ -19,7 +19,7 @@
 
     <sql id="selectFmsBlockHasResVo2">
         select b.blockId, b.landId, b.blockName, b.blockType, b.blockManager, b.blockManagername, b.blockArea,
-        b.blockSeq, b.tid, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon, l.landName,
+        b.blockSeq, b.tid, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon,b.blockTel, l.landName,
         b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,
         (select GROUP_CONCAT(c.cropName) from FmsCrop c
         left join FmsPlan p on p.cropId = c.cropId
@@ -73,7 +73,7 @@
     <select id="selectFmsBlockInfoByBlockId" parameterType="String" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsBlockResVo">
         SELECT b.blockId, b.landId, b.blockName, b.blockType, b.blockManager, b.blockArea,
             b.blockSeq, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon,
-            b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,
+            b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,b.blockTel,
             b.tid, l.landName,
             u.userName as blockManagername, (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = b.blockId) blockPreview
         from FmsBlock b