Explorar o código

区域增加Code,调整相关内容,提高效率。

jz.kai %!s(int64=2) %!d(string=hai) anos
pai
achega
9e73632256
Modificáronse 19 ficheiros con 120 adicións e 101 borrados
  1. 1 0
      common/src/main/java/com/jpsoft/excellent/modules/base/dao/AreaDAO.java
  2. 1 0
      common/src/main/java/com/jpsoft/excellent/modules/base/dao/OrganizationDAO.java
  3. 2 0
      common/src/main/java/com/jpsoft/excellent/modules/base/entity/Area.java
  4. 1 0
      common/src/main/java/com/jpsoft/excellent/modules/base/service/AreaService.java
  5. 1 0
      common/src/main/java/com/jpsoft/excellent/modules/base/service/OrganizationService.java
  6. 6 0
      common/src/main/java/com/jpsoft/excellent/modules/base/service/impl/AreaServiceImpl.java
  7. 6 0
      common/src/main/java/com/jpsoft/excellent/modules/base/service/impl/OrganizationServiceImpl.java
  8. 11 2
      common/src/main/resources/mapper/base/Area.xml
  9. 3 4
      common/src/main/resources/mapper/base/FeedbackOpinion.xml
  10. 3 4
      common/src/main/resources/mapper/base/OfficeOpinion.xml
  11. 4 0
      common/src/main/resources/mapper/base/Organization.xml
  12. 7 8
      common/src/main/resources/mapper/base/WorkStation.xml
  13. 4 5
      common/src/main/resources/mapper/base/WorkWindow.xml
  14. 31 0
      web/src/main/java/com/jpsoft/excellent/modules/base/controller/AreaController.java
  15. 5 15
      web/src/main/java/com/jpsoft/excellent/modules/base/controller/FeedbackOpinionController.java
  16. 4 14
      web/src/main/java/com/jpsoft/excellent/modules/base/controller/OfficeOpinionController.java
  17. 24 8
      web/src/main/java/com/jpsoft/excellent/modules/base/controller/OrganizationController.java
  18. 4 23
      web/src/main/java/com/jpsoft/excellent/modules/base/controller/WorkStationController.java
  19. 2 18
      web/src/main/java/com/jpsoft/excellent/modules/base/controller/WorkWindowController.java

+ 1 - 0
common/src/main/java/com/jpsoft/excellent/modules/base/dao/AreaDAO.java

@@ -17,4 +17,5 @@ public interface AreaDAO {
 	List<Area> search(Map<String,Object> searchParams,List<Sort> sortList);
 	List<Area> getListByParentId(String parentId);
 	Area getByName(String name);
+	List<Area> listByParentId(String parentId);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/excellent/modules/base/dao/OrganizationDAO.java

@@ -18,4 +18,5 @@ public interface OrganizationDAO {
 	String getLevel();
 	Organization findByName(String name);
 	List<Organization> listByGroups(String groupId);
+	List<Organization> findByParentId(String parentId);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/excellent/modules/base/entity/Area.java

@@ -22,6 +22,8 @@ public class Area {
     private String id;
         @ApiModelProperty(value = "上级编号")
     private String parentId;
+    @ApiModelProperty(value = "编码")
+    private String code;
     private String parentName;
     private String parentFullName;
         @ApiModelProperty(value = "区域名称")

+ 1 - 0
common/src/main/java/com/jpsoft/excellent/modules/base/service/AreaService.java

@@ -16,4 +16,5 @@ public interface AreaService {
 	Page<Area> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
 	List<Area> getListByParentId(String parentId);
 	Area getByName(String name);
+	List<Area> listByParentId(String parentId);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/excellent/modules/base/service/OrganizationService.java

@@ -17,4 +17,5 @@ public interface OrganizationService {
 	String getLevel();
 	Organization findByName(String name);
 	List<Organization> listByGroups(String groupId);
+	List<Organization> findByParentId(String parentId);
 }

+ 6 - 0
common/src/main/java/com/jpsoft/excellent/modules/base/service/impl/AreaServiceImpl.java

@@ -79,4 +79,10 @@ public class AreaServiceImpl implements AreaService {
 		// TODO Auto-generated method stub
 		return areaDAO.getByName(name);
 	}
+
+	@Override
+	public List<Area> listByParentId(String parentId){
+		// TODO Auto-generated method stub
+		return areaDAO.listByParentId(parentId);
+	}
 }

+ 6 - 0
common/src/main/java/com/jpsoft/excellent/modules/base/service/impl/OrganizationServiceImpl.java

@@ -84,4 +84,10 @@ public class OrganizationServiceImpl implements OrganizationService {
 		// TODO Auto-generated method stub
 		return organizationDAO.listByGroups(groupId);
 	}
+
+	@Override
+	public List<Organization> findByParentId(String parentId) {
+		// TODO Auto-generated method stub
+		return organizationDAO.findByParentId(parentId);
+	}
 }

+ 11 - 2
common/src/main/resources/mapper/base/Area.xml

@@ -6,6 +6,7 @@
 	<resultMap id="AreaMap" type="com.jpsoft.excellent.modules.base.entity.Area">
 		<id property="id" column="id_" />
 			<result property="parentId" column="parent_id" />
+		<result property="code" column="code_" />
 			<result property="name" column="name_" />
 			<result property="delFlag" column="del_flag" />
 			<result property="createTime" column="create_time" />
@@ -21,11 +22,12 @@
 	-->
 	<![CDATA[
 		insert into base_area
-	    (id_,parent_id,name_,del_flag,create_time,create_by,update_time,update_by)
+	    (id_,parent_id,code_,name_,del_flag,create_time,create_by,update_time,update_by)
 		values
 		(
 #{id,jdbcType=VARCHAR}
 ,#{parentId,jdbcType=VARCHAR}
+,#{code,jdbcType=VARCHAR}
 ,#{name,jdbcType=VARCHAR}
 ,#{delFlag,jdbcType= NUMERIC }
 ,#{createTime,jdbcType= TIMESTAMP }
@@ -44,6 +46,9 @@
 				<if test="parentId!=null">
 		parent_id=#{parentId,jdbcType=VARCHAR},
 		</if>
+			<if test="code!=null">
+				code_=#{code,jdbcType=VARCHAR},
+			</if>
 				<if test="name!=null">
 		name_=#{name,jdbcType=VARCHAR},
 		</if>
@@ -67,7 +72,7 @@
 	</update>
 	<select id="get" parameterType="string" resultMap="AreaMap">
 		select 
-id_,parent_id,name_,del_flag,create_time,create_by,update_time,update_by		from base_area where id_=#{0}
+id_,parent_id,code_,name_,del_flag,create_time,create_by,update_time,update_by		from base_area where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_area where id_=#{0}
@@ -104,4 +109,8 @@ id_,parent_id,name_,del_flag,create_time,create_by,update_time,update_by		from b
 		and name_=#{0}
 		limit 1
 	</select>
+	<select id="listByParentId" resultMap="AreaMap">
+		SELECT * FROM base_area
+		where parent_id = #{0}
+	</select>
 </mapper>

+ 3 - 4
common/src/main/resources/mapper/base/FeedbackOpinion.xml

@@ -133,6 +133,7 @@
 		<![CDATA[
 			select a.*,b.area_id,b.station_name from base_feedback_opinion a
 			left join base_work_station b on a.work_station_id = b.id_
+			LEFT JOIN base_area c ON b.area_id = c.id_
 		]]>
 		<where>
 			and a.del_flag = 0
@@ -148,10 +149,8 @@
 			<if test="searchParams.areaId != null">
 				and b.area_id = #{searchParams.areaId}
 			</if>
-			<if test="searchParams.areaIds != null">
-				<foreach collection="searchParams.areaIds" item="areaId" open="and b.area_id in (" separator="," close=")">
-					#{areaId}
-				</foreach>
+			<if test="searchParams.code != null">
+				and c.code_ like #{searchParams.code}
 			</if>
 			<if test="searchParams.workStation != null">
 				and a.work_station_id = #{searchParams.workStation}

+ 3 - 4
common/src/main/resources/mapper/base/OfficeOpinion.xml

@@ -118,6 +118,7 @@
 		<![CDATA[
 			SELECT a.*,b.area_id,b.name_ AS office_name FROM base_office_opinion a
 			LEFT JOIN base_office b ON a.office_id = b.id_
+			LEFT JOIN base_area c ON b.area_id = c.id_
 		]]>
 		<where>
 			and a.del_flag = 0
@@ -130,10 +131,8 @@
 			<if test="searchParams.areaId != null">
 				and b.area_id = #{searchParams.areaId}
 			</if>
-			<if test="searchParams.areaIds != null">
-				<foreach collection="searchParams.areaIds" item="areaId" open="and b.area_id in (" separator="," close=")">
-					#{areaId}
-				</foreach>
+			<if test="searchParams.code != null">
+				and c.code_ like #{searchParams.code}
 			</if>
 			<if test="searchParams.isSatisfied != null">
 				and a.is_satisfied = #{searchParams.isSatisfied}

+ 4 - 0
common/src/main/resources/mapper/base/Organization.xml

@@ -138,4 +138,8 @@ id_,name_,parent_id,code_,groups_,del_flag,create_time,create_by,update_time,upd
 		where del_flag = 0
 		and groups_ like #{0};
 	</select>
+	<select id="findByParentId" resultMap="OrganizationMap">
+		select * from base_organization
+		where parent_id = #{0};
+	</select>
 </mapper>

+ 7 - 8
common/src/main/resources/mapper/base/WorkStation.xml

@@ -77,23 +77,22 @@ id_,area_id,station_name,del_flag,create_time,create_by,update_time,update_by		f
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="WorkStationMap">
 		<![CDATA[
-			select * from base_work_station
+			select * from base_work_station a
+			LEFT JOIN base_area b ON a.area_id = b.id_
 		]]>
 		<where>
 			del_flag = 0
 			<if test="searchParams.areaId != null">
-				and area_id = #{searchParams.areaId}
+				and a.area_id = #{searchParams.areaId}
 			</if>
-			<if test="searchParams.areaIds != null">
-				<foreach collection="searchParams.areaIds" item="areaId" open="and area_id in (" separator="," close=")">
-					#{areaId}
-				</foreach>
+			<if test="searchParams.code != null">
+				and b.code_ like #{searchParams.code}
 			</if>
 			<if test="searchParams.stationId != null">
-				and station_id = #{searchParams.stationId}
+				and a.station_id = #{searchParams.stationId}
 			</if>
 			<if test="searchParams.stationName != null">
-				and station_name like #{searchParams.stationName}
+				and a.station_name like #{searchParams.stationName}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 4 - 5
common/src/main/resources/mapper/base/WorkWindow.xml

@@ -82,6 +82,7 @@
 		<![CDATA[
 			select a.*,b.station_name from base_work_window a
 			left join base_work_station b on a.station_id = b.id_
+			LEFT JOIN base_area c ON b.area_id = c.id_
 		]]>
 		<where>
 			a.del_flag = 0
@@ -91,14 +92,12 @@
 			<if test="searchParams.windowName != null">
 				and a.window_name like #{searchParams.windowName}
 			</if>
-			<if test="searchParams.areaIds != null">
-				<foreach collection="searchParams.areaIds" item="areaId" open="and b.area_id in (" separator="," close=")">
-					#{areaId}
-				</foreach>
-			</if>
 			<if test="searchParams.areaId != null">
 				and b.area_id = #{searchParams.areaId}
 			</if>
+			<if test="searchParams.code != null">
+				and c.code_ like #{searchParams.code}
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 31 - 0
web/src/main/java/com/jpsoft/excellent/modules/base/controller/AreaController.java

@@ -58,6 +58,14 @@ public class AreaController {
             area.setCreateBy(subject);
             area.setCreateTime(new Date());
 
+            Area areaParent = areaService.get(area.getParentId());
+            if(areaParent != null){
+                area.setCode(areaParent.getCode() + "," + area.getId());
+            }
+            else{
+                area.setCode(area.getId());
+            }
+
             int affectCount = areaService.insert(area);
 
             if (affectCount > 0) {
@@ -113,9 +121,19 @@ public class AreaController {
             area.setUpdateBy(subject);
             area.setUpdateTime(new Date());
 
+            Area areaParent = areaService.get(area.getParentId());
+            if(areaParent != null){
+                area.setCode(areaParent.getCode() + "," + area.getId());
+            }
+            else{
+                area.setCode(area.getId());
+            }
+
             int affectCount = areaService.update(area);
 
             if (affectCount > 0) {
+                updateChildCode(area.getId());
+
                 msgResult.setResult(true);
                 msgResult.setData(area);
             } else {
@@ -133,6 +151,19 @@ public class AreaController {
         return msgResult;
     }
 
+    @ApiOperation(value="更新code")
+    @PostMapping("updateChildCode")
+    public void updateChildCode(String parentId){
+        Area area = areaService.get(parentId);
+        List<Area> childList = areaService.listByParentId(parentId);
+        for(Area child : childList){
+            child.setCode(area.getCode() + "," + child.getId());
+            areaService.update(child);
+
+            updateChildCode(child.getId());
+        }
+    }
+
     @ApiOperation(value="删除")
     @PostMapping("delete/{id}")
     public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){

+ 5 - 15
web/src/main/java/com/jpsoft/excellent/modules/base/controller/FeedbackOpinionController.java

@@ -316,7 +316,8 @@ public class FeedbackOpinionController {
         }
         if (StringUtils.isNotEmpty(areaId) && !"null".equals(areaId)) {
             if (areaSubordinate) {
-                searchParams.put("areaIds", parentIds(areaId));
+                Area area = areaService.get(areaId);
+                searchParams.put("code", area.getCode() + "%");
             }
             else {
                 searchParams.put("areaId", areaId);
@@ -450,7 +451,8 @@ public class FeedbackOpinionController {
         }
         if (StringUtils.isNotEmpty(areaId) && !"null".equals(areaId)) {
             if (areaSubordinate) {
-                searchParams.put("areaIds", parentIds(areaId));
+                Area area = areaService.get(areaId);
+                searchParams.put("code", area.getCode() + "%");
             }
             else {
                 searchParams.put("areaId", areaId);
@@ -665,7 +667,7 @@ public class FeedbackOpinionController {
                 Integer countYQR = 0;
                 Integer countWQR = 0;
 
-                searchParams.put("areaIds", parentIds(area.getId()));
+                searchParams.put("code", area.getCode() + "%");
                 Page<FeedbackOpinion> page = feedbackOpinionService.pageSearch(searchParams, 1, 10000, false, sortList);
                 for (FeedbackOpinion feedbackOpinion : page.getResult()) {
                     if (feedbackOpinion.getIsSatisfied() != null && feedbackOpinion.getIsSatisfied()) {
@@ -703,18 +705,6 @@ public class FeedbackOpinionController {
         return msgResult;
     }
 
-    private List<String> parentIds(String parentId){
-        List<String> ids = new ArrayList<>();
-        ids.add(parentId);
-
-        List<Area> areaList = areaService.getListByParentId(parentId);
-        for(Area area : areaList){
-            ids.addAll(parentIds(area.getId()));
-        }
-
-        return ids;
-    }
-
     @ApiOperation(value="导出报表")
     @RequestMapping(value = "reportXls",method = RequestMethod.POST)
     public String reportXls(@RequestBody FeedbackOpinionReportDTO feedbackOpinionReportDTO){

+ 4 - 14
web/src/main/java/com/jpsoft/excellent/modules/base/controller/OfficeOpinionController.java

@@ -297,7 +297,8 @@ public class OfficeOpinionController {
         }
         if (StringUtils.isNotEmpty(areaId) && !"null".equals(areaId)) {
             if (areaSubordinate) {
-                searchParams.put("areaIds", parentIds(areaId));
+                Area area = areaService.get(areaId);
+                searchParams.put("code", area.getCode() + "%");
             }
             else {
                 searchParams.put("areaId", areaId);
@@ -398,18 +399,6 @@ public class OfficeOpinionController {
         return msgResult;
     }
 
-    private List<String> parentIds(String parentId){
-        List<String> ids = new ArrayList<>();
-        ids.add(parentId);
-
-        List<Area> areaList = areaService.getListByParentId(parentId);
-        for(Area area : areaList){
-            ids.addAll(parentIds(area.getId()));
-        }
-
-        return ids;
-    }
-
     @ApiOperation(value="导出报表")
     @RequestMapping(value = "reportListXls",method = RequestMethod.POST)
     public String reportListXls(String sort, String connect, String connectPhone, String areaId, String workStation, String window,
@@ -471,7 +460,8 @@ public class OfficeOpinionController {
         }
         if (StringUtils.isNotEmpty(areaId) && !"null".equals(areaId)) {
             if (areaSubordinate) {
-                searchParams.put("areaIds", parentIds(areaId));
+                Area area = areaService.get(areaId);
+                searchParams.put("code", area.getCode() + "%");
             }
             else {
                 searchParams.put("areaId", areaId);

+ 24 - 8
web/src/main/java/com/jpsoft/excellent/modules/base/controller/OrganizationController.java

@@ -25,6 +25,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -139,16 +140,20 @@ public class OrganizationController {
             organization.setGroups(StringUtils.join(organization.getArrGroups(),","));
             organization.setUpdateBy(subject);
             organization.setUpdateTime(new Date());
-            
-            int affectCount = organizationService.update(organization);
 
-            if (affectCount > 0) {
-                msgResult.setResult(true);
-                msgResult.setData(organization);
-            } else {
-                msgResult.setResult(false);
-                msgResult.setMessage("数据库更新失败");
+            Organization org = organizationService.get(organization.getParentId());
+            if(org != null){
+                organization.setCode(org.getCode() + "," + organization.getId());
             }
+            else{
+                organization.setCode(organization.getId());
+            }
+            
+            organizationService.update(organization);
+            updateChildCode(organization.getId());
+
+            msgResult.setResult(true);
+            msgResult.setData(organization);
         }
         catch(Exception ex){
             logger.error(ex.getMessage(),ex);
@@ -160,6 +165,17 @@ public class OrganizationController {
         return msgResult;
     }
 
+    private void updateChildCode(String parentId){
+        Organization organization = organizationService.get(parentId);
+        List<Organization> childList = organizationService.findByParentId(parentId);
+        for(Organization child : childList){
+            child.setCode(organization.getCode() + "," + child.getId());
+            organizationService.update(child);
+
+            updateChildCode(child.getId());
+        }
+    }
+
 	@ApiOperation(value="删除")
     @PostMapping("delete/{id}")
     public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){

+ 4 - 23
web/src/main/java/com/jpsoft/excellent/modules/base/controller/WorkStationController.java

@@ -236,11 +236,8 @@ public class WorkStationController {
         sortList.add(new Sort("station_name","asc"));
 
         if (StringUtils.isNotEmpty(areaId)) {
-            List<String> areaIds = new ArrayList<>();
-            areaIds.add(areaId);
-            areaIds.addAll(parentIds(areaId));
-
-            searchParams.put("areaIds",areaIds);
+            Area area = areaService.get(areaId);
+            searchParams.put("code", area.getCode() + "%");
         }
         if (StringUtils.isNotEmpty(stationName)) {
             searchParams.put("stationName","%"+stationName+"%");
@@ -406,19 +403,6 @@ public class WorkStationController {
         return fullName;
     }
 
-    private List<String> parentIds(String parentId){
-        List<String> ids = new ArrayList<>();
-
-        List<Area> areaList = areaService.getListByParentId(parentId);
-        for(Area area : areaList){
-            ids.add(area.getId());
-
-            ids.addAll(parentIds(area.getId()));
-        }
-
-        return ids;
-    }
-
     @ApiOperation(value="获取站点")
     @PostMapping("stationList")
     public List<WorkStation> stationList(String areaId){
@@ -447,11 +431,8 @@ public class WorkStationController {
         sortList.add(new Sort("create_time","asc"));
 
         if (StringUtils.isNotEmpty(areaId)) {
-            List<String> areaIds = new ArrayList<>();
-            areaIds.add(areaId);
-            areaIds.addAll(parentIds(areaId));
-
-            searchParams.put("areaIds",areaIds);
+            Area area = areaService.get(areaId);
+            searchParams.put("code", area.getCode() + "%");
         }
 
         Page<WorkStation> page = workStationService.pageSearch(searchParams,1,10000,false,sortList);

+ 2 - 18
web/src/main/java/com/jpsoft/excellent/modules/base/controller/WorkWindowController.java

@@ -223,11 +223,8 @@ public class WorkWindowController {
             searchParams.put("windowName","%" + windowName + "%");
         }
         if (StringUtils.isNotEmpty(areaId)) {
-            List<String> areaIds = new ArrayList<>();
-            areaIds.add(areaId);
-            areaIds.addAll(parentIds(areaId));
-
-            searchParams.put("areaIds",areaIds);
+            Area area = areaService.get(areaId);
+            searchParams.put("code", area.getCode() + "%");
         }
 
         Page<WorkWindow> page = workWindowService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
@@ -260,17 +257,4 @@ public class WorkWindowController {
 
         return names;
     }
-
-    private List<String> parentIds(String parentId){
-        List<String> ids = new ArrayList<>();
-
-        List<Area> areaList = areaService.getListByParentId(parentId);
-        for(Area area : areaList){
-            ids.add(area.getId());
-
-            ids.addAll(parentIds(area.getId()));
-        }
-
-        return ids;
-    }
 }