Przeglądaj źródła

场地管理模块添加所属区域属性。

bruce 2 lat temu
rodzic
commit
2ecfcfdd76

+ 2 - 2
doc/sql/update/bt-2301-2月份需求.sql

@@ -1,5 +1,5 @@
--- 数据字典:所属区域
-INSERT INTO zuihou_base_bt_0000.c_common_dictionary (id,type_,name,describe_,status_,create_user,create_time) VALUES (7,'REGION','所属区域','',1,3,'2023-02-20 15:06:33');
+-- 数据字典:所属区域【界面中手动添加】
+-- INSERT INTO zuihou_base_bt_0000.c_common_dictionary (id,type_,name,describe_,status_,create_user,create_time) VALUES (7,'REGION','所属区域','',1,3,'2023-02-20 15:06:33');
 
 -- 新增 所属区域 字段
 ALTER TABLE zuihou_base_bt_0000.c_core_org ADD region_id BIGINT(20) NULL COMMENT '所属区域ID(数据字典项 - REGION)';

+ 4 - 1
imcs-bt-be/imcs-authority-biz/src/main/resources/mapper_authority/base/core/OrgMapper.xml

@@ -16,12 +16,15 @@
         <result column="sort_value" jdbcType="INTEGER" property="sortValue"/>
         <result column="status" jdbcType="BIT" property="status"/>
         <result column="describe_" jdbcType="VARCHAR" property="describe"/>
+        <result column="com_id" jdbcType="BIGINT" property="comId"/>
+        <result column="region_id" jdbcType="BIGINT" property="regionId"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, create_time, create_user, update_time, update_user,
-        label, abbreviation, parent_id, tree_path, sort_value, status, describe_
+        label, abbreviation, parent_id, tree_path, sort_value, status, describe_,
+        com_id, region_id
     </sql>
 
     <select id="getOrgList" resultType="com.github.zuihou.authority.entity.core.Org">

+ 4 - 28
imcs-bt-be/imcs-authority-entity/src/main/java/com/github/zuihou/authority/entity/core/Org.java

@@ -11,7 +11,6 @@ import lombok.experimental.Accessors;
 import org.hibernate.validator.constraints.Length;
 
 import javax.validation.constraints.NotNull;
-import java.time.LocalDateTime;
 
 import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
 
@@ -21,14 +20,11 @@ import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
  * @author zuihou
  * @since 2019-10-20
  */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@ToString(callSuper = true)
-@EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
 @TableName("c_core_org")
+@Accessors(chain = true)
 @ApiModel(value = "Org", description = "组织")
+@Data @Builder @NoArgsConstructor @AllArgsConstructor
+@ToString(callSuper = true) @EqualsAndHashCode(callSuper = true)
 public class Org extends TreeEntity<Org, Long>
 {
     private static final long serialVersionUID = 1L;
@@ -82,7 +78,7 @@ public class Org extends TreeEntity<Org, Long>
     /**
      * 所属区域id
      */
-    @ApiModelProperty(value = "所属区域")
+    @ApiModelProperty(value = "所属区域id")
     @NotNull(message = "请选择所属区域")
     private Long regionId;
 
@@ -91,24 +87,4 @@ public class Org extends TreeEntity<Org, Long>
 
     @TableField(exist = false)
     private Long value;
-
-    @Builder
-    public Org(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
-               String label, String abbreviation, Long parentId, String treePath, Integer sortValue,
-               Boolean status, String describe, Long regionId)
-    {
-        this.id = id;
-        this.createTime = createTime;
-        this.createUser = createUser;
-        this.updateTime = updateTime;
-        this.updateUser = updateUser;
-        this.label = label;
-        this.abbreviation = abbreviation;
-        this.parentId = parentId;
-        this.treePath = treePath;
-        this.sortValue = sortValue;
-        this.status = status;
-        this.describe = describe;
-        this.regionId = regionId;
-    }
 }

+ 81 - 35
imcs-bt-be/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/place/PlaceController.java

@@ -2,7 +2,9 @@ package com.github.zuihou.business.controller.place;
 
 import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.authority.dao.common.DictionaryItemMapper;
 import com.github.zuihou.authority.entity.auth.User;
+import com.github.zuihou.authority.entity.common.DictionaryItem;
 import com.github.zuihou.authority.entity.core.Org;
 import com.github.zuihou.authority.service.auth.UserService;
 import com.github.zuihou.authority.service.core.OrgService;
@@ -18,12 +20,14 @@ import com.github.zuihou.business.place.service.PlaceService;
 
 import java.lang.reflect.Array;
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.R;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import io.swagger.annotations.Api;
@@ -35,34 +39,40 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import com.github.zuihou.security.annotation.PreAuth;
 
+import javax.annotation.Resource;
 
 /**
- * <p>
- * 前端控制器
- * 场地管理
- * </p>
+ * 场地管理前端控制器
  *
  * @author zuihou
  * @date 2022-01-08
  */
-@Slf4j
-@Validated
-@RestController
-@RequestMapping("/place")
-@Api(value = "Place", tags = "场地管理")
+@Validated @Slf4j
 @PreAuth(replace = "place:")
-public class PlaceController extends SuperController<PlaceService, Long, Place, PlacePageDTO, PlaceSaveDTO,
-        PlaceUpdateDTO> {
-    @Autowired
+@Api(value = "Place", tags = "场地管理")
+@RestController @RequestMapping("/place")
+public class PlaceController extends SuperController<PlaceService, Long, Place, PlacePageDTO, PlaceSaveDTO, PlaceUpdateDTO>
+{
+    @Resource
     private UserService userService;
-
-    @Autowired
+    @Resource
     private OrgService orgService;
+    @Resource
+    private DictionaryItemMapper dictionaryItemMapper;
 
+    /**
+     * 分页查询
+     *
+     * @param params  查询参数
+     * @param page    分页信息
+     * @param defSize def大小
+     */
     @Override
-    public void query(PageParams<PlacePageDTO> params, IPage<Place> page, Long defSize) {
+    public void query(PageParams<PlacePageDTO> params, IPage<Place> page, Long defSize)
+    {
         PlacePageDTO data = params.getModel();
         Place model = BeanUtil.toBean(data, Place.class);
+
         QueryWrap<Place> wrapper = this.handlerWrapper(null, params);
         LbqWrapper<Place> lbqWrapper = wrapper.lambda();
         lbqWrapper.like(Place::getPlcName, model.getPlcName());
@@ -70,68 +80,104 @@ public class PlaceController extends SuperController<PlaceService, Long, Place,
         lbqWrapper.eq(Place::getPlcAid, model.getPlcAid());
         lbqWrapper.eq(Place::getPlcCid, model.getPlcCid());
         baseService.page(page, wrapper);
+
+        List<Long> regionIds = new LinkedList<>();
         List<Place> placeList = page.getRecords();
-        for (Place place : placeList) {
+        for (Place place : placeList)
+        {
             String[] arr = {place.getPlcPid(), place.getPlcCid(), place.getPlcAid()};
             place.setPlcComDesc(getPlaceComDescById(place.getCreateUser()));
             place.setSelectedOptions(arr);
+
+            if (null != place.getRegionId())
+            {
+                regionIds.add(place.getRegionId());
+            }
+        }
+
+        // 补充所属区域属性
+        if (regionIds.size() > 0)
+        {
+           Map<Long, String> names = dictionaryItemMapper.selectBatchIds(regionIds).stream()
+              .collect(Collectors.toMap(DictionaryItem::getId, DictionaryItem::getName));
+
+            placeList.forEach(p -> p.setRegion(names.getOrDefault(p.getRegionId(), "")));
         }
     }
 
     /**
      * Excel导入后的操作
      *
-     * @param list
+     * @param list 导入数据
      */
     @Override
-    public R<Boolean> handlerImport(List<Map<String, String>> list) {
-        List<Place> placeList = list.stream().map((map) -> {
+    public R<Boolean> handlerImport(List<Map<String, String>> list)
+    {
+        List<Place> placeList = list.stream()
+          .map((map) ->
+          {
             Place place = Place.builder().build();
             //TODO 请在这里完成转换
             return place;
-        }).collect(Collectors.toList());
+          })
+          .collect(Collectors.toList());
 
         return R.success(baseService.saveBatch(placeList));
     }
 
-    @ApiOperation(value = "查询所有场地", notes = "查询所有场地")
     @GetMapping("/getAll")
-    public R<List<Place>> getAll(@RequestParam(value = "id", required = false) Long id) {
+    @ApiOperation(value = "查询所有场地", notes = "查询所有场地")
+    public R<List<Place>> getAll(@RequestParam(value = "id", required = false) Long id)
+    {
         return R.success(baseService.getAll(id));
     }
 
-    private String getPlaceComDescById(long userId) {
+    private String getPlaceComDescById(long userId)
+    {
         String comDesc = "";
         User user = userService.getById(userId);
-        if(user == null){
+        if (user == null)
+        {
             return comDesc;
         }
+
         Org org = orgService.getById(user.getOrg().getKey());
-        if(org == null){
+        if (org == null)
+        {
             return comDesc;
         }
+
         String treePath = org.getTreePath();
         String[] treeArray = treePath.split(",");
-        if (treeArray != null) {
-            if (treeArray.length == 0) {
+        if (treeArray != null)
+        {
+            if (treeArray.length == 0)
+            {
                 comDesc = org.getLabel();
-            } else if (treeArray.length == 2) {
-                if (org.getLabel().contains("分管")) {
+            }
+            else if (treeArray.length == 2)
+            {
+                if (org.getLabel().contains("分管"))
+                {
                     Org parentOrg = orgService.getById(org.getParentId());
                     comDesc = parentOrg.getLabel();
-                } else {
+                }
+                else
+                {
                     comDesc = org.getLabel();
                 }
-
-            } else if (treeArray.length > 2) {
+            }
+            else if (treeArray.length > 2)
+            {
                 String pOrgId = treeArray[2];
-                if (StringUtils.isNotEmpty(pOrgId)) {
+                if (StringUtils.isNotEmpty(pOrgId))
+                {
                     Org parentOrg = orgService.getById(Long.parseLong(pOrgId));
                     comDesc = parentOrg.getLabel();
                 }
-
             }
         }
+
         return comDesc;
     }
-}
+}

+ 15 - 27
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/place/dto/PlaceSaveDTO.java

@@ -1,43 +1,26 @@
 package com.github.zuihou.business.place.dto;
 
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.github.zuihou.base.entity.Entity;
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import org.hibernate.validator.constraints.Length;
-import org.hibernate.validator.constraints.Range;
-import lombok.Data;
-import lombok.Builder;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-import lombok.AllArgsConstructor;
-import lombok.ToString;
+import lombok.*;
 import lombok.experimental.Accessors;
-import com.github.zuihou.common.constant.DictionaryType;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
- * <p>
- * 实体类
- * 场地管理
- * </p>
+ * 场地新增DTO
  *
  * @author zuihou
  * @since 2022-01-08
  */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
 @Accessors(chain = true)
-@ToString(callSuper = true)
-@EqualsAndHashCode(callSuper = false)
-@Builder
 @ApiModel(value = "PlaceSaveDTO", description = "场地管理")
-public class PlaceSaveDTO implements Serializable {
-
+@Data @Builder @NoArgsConstructor @AllArgsConstructor
+@ToString(callSuper = true) @EqualsAndHashCode(callSuper = false)
+public class PlaceSaveDTO implements Serializable
+{
     private static final long serialVersionUID = 1L;
 
     /**
@@ -144,5 +127,10 @@ public class PlaceSaveDTO implements Serializable {
     @ApiModelProperty(value = "场地维度")
     @Length(max = 255, message = "场地维度长度不能超过10")
     private String plcLat;
-
+    /**
+     * 所属区域id
+     */
+    @ApiModelProperty(value = "所属区域id")
+    @NotNull(message = "请选择所属区域")
+    private Long regionId;
 }

+ 16 - 27
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/place/dto/PlaceUpdateDTO.java

@@ -1,44 +1,27 @@
 package com.github.zuihou.business.place.dto;
 
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.github.zuihou.base.entity.Entity;
-import com.baomidou.mybatisplus.annotation.TableField;
+import com.github.zuihou.base.entity.SuperEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import org.hibernate.validator.constraints.Length;
-import org.hibernate.validator.constraints.Range;
-import com.github.zuihou.base.entity.SuperEntity;
-import lombok.Data;
-import lombok.Builder;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-import lombok.AllArgsConstructor;
-import lombok.ToString;
+import lombok.*;
 import lombok.experimental.Accessors;
-import com.github.zuihou.common.constant.DictionaryType;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
- * <p>
- * 实体类
- * 场地管理
- * </p>
+ * 场地修改DTO
  *
  * @author zuihou
  * @since 2022-01-08
  */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
 @Accessors(chain = true)
-@ToString(callSuper = true)
-@EqualsAndHashCode(callSuper = false)
-@Builder
 @ApiModel(value = "PlaceUpdateDTO", description = "场地管理")
-public class PlaceUpdateDTO implements Serializable {
-
+@Data @Builder @NoArgsConstructor @AllArgsConstructor
+@ToString(callSuper = true) @EqualsAndHashCode(callSuper = false)
+public class PlaceUpdateDTO implements Serializable
+{
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty(value = "主键")
@@ -149,4 +132,10 @@ public class PlaceUpdateDTO implements Serializable {
     @ApiModelProperty(value = "场地维度")
     @Length(max = 255, message = "场地维度长度不能超过10")
     private String plcLat;
+    /**
+     * 所属区域id
+     */
+    @ApiModelProperty(value = "所属区域id")
+    @NotNull(message = "请选择所属区域")
+    private Long regionId;
 }

+ 17 - 42
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/place/entity/Place.java

@@ -25,24 +25,18 @@ import static com.github.zuihou.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
 import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
 
 /**
- * <p>
- * 实体类
- * 场地管理
- * </p>
+ * 场地管理实体类
  *
  * @author zuihou
  * @since 2022-01-08
  */
-@Data
-@NoArgsConstructor
-@ToString(callSuper = true)
-@EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
 @TableName("bt_place")
+@Accessors(chain = true)
 @ApiModel(value = "Place", description = "场地管理")
-@AllArgsConstructor
-public class Place extends Entity<Long> {
-
+@Data @Builder @NoArgsConstructor @AllArgsConstructor
+@ToString(callSuper = true) @EqualsAndHashCode(callSuper = true)
+public class Place extends Entity<Long>
+{
     private static final long serialVersionUID = 1L;
 
     /**
@@ -215,35 +209,16 @@ public class Place extends Entity<Long> {
     @TableField(exist = false)
     private String [] selectedOptions;
 
+    /**
+     * 所属区域id
+     */
+    @ApiModelProperty(value = "所属区域id")
+    @NotNull(message = "请选择所属区域")
+    private Long regionId;
 
-    @Builder
-    public Place(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 
-                    String plcName, String plcPid, String plcCid, String plcAid, String plcRoad,
-                    String plcNum, String plcEvnType, String plcAbv, String plcPotSpc, String plcBnsType, String plcIscuspot, 
-                    String plcIscuslin, String plcInoutdoor, Long plcComid, String plcStatus, String plcRemark, String plcLog, String plcLat) {
-        this.id = id;
-        this.createTime = createTime;
-        this.createUser = createUser;
-        this.updateTime = updateTime;
-        this.updateUser = updateUser;
-        this.plcName = plcName;
-        this.plcPid = plcPid;
-        this.plcCid = plcCid;
-        this.plcAid = plcAid;
-        this.plcRoad = plcRoad;
-        this.plcNum = plcNum;
-        this.plcEvnType = plcEvnType;
-        this.plcAbv = plcAbv;
-        this.plcPotSpc = plcPotSpc;
-        this.plcBnsType = plcBnsType;
-        this.plcIscuspot = plcIscuspot;
-        this.plcIscuslin = plcIscuslin;
-        this.plcInoutdoor = plcInoutdoor;
-        this.plcComid = plcComid;
-        this.plcStatus = plcStatus;
-        this.plcRemark = plcRemark;
-        this.plcLng = plcLog;
-        this.plcLat = plcLat;
-    }
-
+    /**
+     * 所属区域
+     */
+    @TableField(exist = false)
+    private String region;
 }