Преглед изворни кода

运营开发巡检任务功能

wuxw пре 1 година
родитељ
комит
8db9f4357b

+ 9 - 0
java110-bean/src/main/java/com/java110/vo/api/inspectionTask/ApiInspectionTaskDataVo.java

@@ -18,6 +18,7 @@ public class ApiInspectionTaskDataVo implements Serializable {
     private String inspectionPlanName;
     private String planUserName;
     private String communityId;
+    private String communityName;
     private String bId;
     private String actUserId;
     private String taskId;
@@ -224,4 +225,12 @@ public class ApiInspectionTaskDataVo implements Serializable {
     public void setInspectionRouteId(String inspectionRouteId) {
         this.inspectionRouteId = inspectionRouteId;
     }
+
+    public String getCommunityName() {
+        return communityName;
+    }
+
+    public void setCommunityName(String communityName) {
+        this.communityName = communityName;
+    }
 }

+ 18 - 0
java110-db/src/main/resources/mapper/report/ReportCommunityServiceDaoImplMapper.xml

@@ -326,6 +326,24 @@
         </if>
         order by t.repair_type_name
     </select>
+    <select id="queryCommunityInspectionTree" parameterType="Map" resultType="Map">
+        select s.community_id communityId,s.`name` communityName,ip.inspection_plan_id inspectionPlanId,
+        ip.inspection_plan_name inspectionPlanName ,t.staff_id staffId,t.staff_name staffName
+        from inspection_plan_staff t
+        left join inspection_plan ip on t.inspection_plan_id = ip.inspection_plan_id and ip.status_cd = '0'
+        left join s_community s on t.community_id = s.community_id and s.status_cd = '0'
+        where t.status_cd = '0'
+        and ip.status_cd = '0'
+        and s.status_cd = '0'
+        <if test="communityIds !=null ">
+            and s.community_id in
+            <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        order by ip.create_time desc
+    </select>
+
 
     <select id="queryHisOwnerCarCount" parameterType="Map" resultType="Map">
         select count(1) count

+ 4 - 0
java110-interface/src/main/java/com/java110/intf/report/IReportCommunityInnerServiceSMO.java

@@ -2,6 +2,7 @@ package com.java110.intf.report;
 
 import com.java110.config.feign.FeignConfiguration;
 import com.java110.dto.fee.FeeConfigDto;
+import com.java110.dto.inspection.InspectionPlanDto;
 import com.java110.dto.parking.ParkingAreaDto;
 import com.java110.dto.repair.RepairSettingDto;
 import com.java110.dto.room.RoomDto;
@@ -113,4 +114,7 @@ public interface IReportCommunityInnerServiceSMO {
 
     @RequestMapping(value = "/queryCommunityRepairTree", method = RequestMethod.POST)
     List<RepairSettingDto> queryCommunityRepairTree(@RequestBody RepairSettingDto repairSettingDto);
+
+    @RequestMapping(value = "/queryCommunityInspectionTree", method = RequestMethod.POST)
+    List<InspectionPlanDto> queryCommunityInspectionTree(@RequestBody InspectionPlanDto inspectionPlanDto);
 }

+ 39 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionTask/ListAdminInspectionTasksCmd.java

@@ -20,11 +20,15 @@ import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.community.CommunityDto;
 import com.java110.dto.inspection.InspectionTaskDto;
+import com.java110.dto.repair.RepairDto;
+import com.java110.intf.community.ICommunityV1InnerServiceSMO;
 import com.java110.intf.community.IInspectionTaskInnerServiceSMO;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.ListUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.api.inspectionTask.ApiInspectionTaskDataVo;
 import com.java110.vo.api.inspectionTask.ApiInspectionTaskVo;
@@ -55,6 +59,9 @@ public class ListAdminInspectionTasksCmd extends Cmd {
     @Autowired
     private IInspectionTaskInnerServiceSMO inspectionTaskInnerServiceSMOImpl;
 
+    @Autowired
+    private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         super.validatePageInfo(reqJson);
@@ -84,6 +91,8 @@ public class ListAdminInspectionTasksCmd extends Cmd {
             inspectionTasks = new ArrayList<>();
         }
 
+        refreshCommunityName(inspectionTasks);
+
         ApiInspectionTaskVo apiInspectionTaskVo = new ApiInspectionTaskVo();
 
         apiInspectionTaskVo.setTotal(count);
@@ -95,4 +104,34 @@ public class ListAdminInspectionTasksCmd extends Cmd {
         cmdDataFlowContext.setResponseEntity(responseEntity);
 
     }
+
+    private void refreshCommunityName(List<ApiInspectionTaskDataVo> inspectionTasks) {
+
+        if(ListUtil.isNull(inspectionTasks)){
+            return;
+        }
+
+        List<String> communityIds = new ArrayList<>();
+        for (ApiInspectionTaskDataVo apiInspectionTaskDataVo : inspectionTasks) {
+            communityIds.add(apiInspectionTaskDataVo.getCommunityId());
+        }
+
+        if(ListUtil.isNull(communityIds)){
+            return ;
+        }
+        CommunityDto communityDto = new CommunityDto();
+        communityDto.setCommunityIds(communityIds.toArray(new String[communityIds.size()]));
+        List<CommunityDto> communityDtos = communityV1InnerServiceSMOImpl.queryCommunitys(communityDto);
+        if(ListUtil.isNull(communityDtos)){
+            return;
+        }
+        for (ApiInspectionTaskDataVo apiInspectionTaskDataVo : inspectionTasks) {
+            for (CommunityDto tCommunityDto : communityDtos) {
+                if (!apiInspectionTaskDataVo.getCommunityId().equals(tCommunityDto.getCommunityId())) {
+                    continue;
+                }
+                apiInspectionTaskDataVo.setCommunityName(tCommunityDto.getName());
+            }
+        }
+    }
 }

+ 191 - 0
service-report/src/main/java/com/java110/report/cmd/community/QueryCommunityInspectionTreeCmd.java

@@ -0,0 +1,191 @@
+package com.java110.report.cmd.community;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.inspection.InspectionPlanDto;
+import com.java110.intf.dev.IDictV1InnerServiceSMO;
+import com.java110.intf.report.IReportCommunityInnerServiceSMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 查询小区巡检树形结构
+ */
+@Java110Cmd(serviceCode = "community.queryCommunityInspectionTree")
+public class QueryCommunityInspectionTreeCmd extends Cmd {
+
+    @Autowired
+    private IReportCommunityInnerServiceSMO reportCommunityInnerServiceSMOImpl;
+
+    @Autowired
+    private IDictV1InnerServiceSMO dictV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        // must be administrator
+        super.validateAdmin(context);
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        List<InspectionPlanDto> inspectionPlanDtos = null;
+
+        InspectionPlanDto inspectionPlanDto = new InspectionPlanDto();
+
+
+        inspectionPlanDtos = reportCommunityInnerServiceSMOImpl.queryCommunityInspectionTree(inspectionPlanDto);
+        JSONArray communitys = new JSONArray();
+        if (ListUtil.isNull(inspectionPlanDtos)) {
+            context.setResponseEntity(ResultVo.createResponseEntity(communitys));
+            return;
+        }
+
+        JSONObject communityInfo = null;
+        for (InspectionPlanDto tmpInspectionPlanDto : inspectionPlanDtos) {
+            if (!hasInCommunity(tmpInspectionPlanDto, communitys)) {
+                communityInfo = new JSONObject();
+                communityInfo.put("id", "c_" + tmpInspectionPlanDto.getCommunityId());
+                communityInfo.put("communityId", tmpInspectionPlanDto.getCommunityId());
+                communityInfo.put("text", tmpInspectionPlanDto.getCommunityName());
+                communityInfo.put("icon", "/img/org.png");
+                communityInfo.put("children", new JSONArray());
+                communitys.add(communityInfo);
+            }
+        }
+
+
+        JSONObject community = null;
+        for (int cIndex = 0; cIndex < communitys.size(); cIndex++) {
+            community = communitys.getJSONObject(cIndex);
+            // find floor data in unitDtos
+            findInspectionPlan(community, inspectionPlanDtos);
+        }
+        context.setResponseEntity(ResultVo.createResponseEntity(communitys));
+
+
+    }
+
+    /**
+     * find community floor data
+     *
+     * @param community       current community
+     * @param inspectionPlanDtos all units data
+     */
+    private void findInspectionPlan(JSONObject community, List<InspectionPlanDto> inspectionPlanDtos) {
+        JSONArray plans = community.getJSONArray("children");
+        JSONObject parkingInfo = null;
+        for (InspectionPlanDto tmpInspectionPlanDto : inspectionPlanDtos) {
+            if(!community.getString("communityId").equals(tmpInspectionPlanDto.getCommunityId())){
+                continue;
+            }
+            if (!hasInInspectionPlan(tmpInspectionPlanDto, plans)) {
+                parkingInfo = new JSONObject();
+                parkingInfo.put("id", "p_" + tmpInspectionPlanDto.getInspectionPlanId());
+                parkingInfo.put("inspectionPlanId", tmpInspectionPlanDto.getInspectionPlanId());
+                parkingInfo.put("communityId", community.getString("communityId"));
+                parkingInfo.put("text", tmpInspectionPlanDto.getInspectionPlanName());
+                parkingInfo.put("icon", "/img/floor.png");
+                parkingInfo.put("children", new JSONArray());
+                plans.add(parkingInfo);
+            }
+        }
+
+
+        JSONObject plan = null;
+        for (int cIndex = 0; cIndex < plans.size(); cIndex++) {
+            plan = plans.getJSONObject(cIndex);
+            // find floor data in unitDtos
+            findInspectionStaff(plan, inspectionPlanDtos);
+        }
+    }
+
+    private void findInspectionStaff(JSONObject plan, List<InspectionPlanDto> inspectionPlanDtos) {
+        JSONArray staffs = plan.getJSONArray("children");
+        JSONObject unitInfo = null;
+        for (InspectionPlanDto tmpInspectionPlanDto : inspectionPlanDtos) {
+            if(!plan.getString("communityId").equals(tmpInspectionPlanDto.getCommunityId())){
+                continue;
+            }
+            if(!plan.getString("inspectionPlanId").equals(tmpInspectionPlanDto.getInspectionPlanId())){
+                continue;
+            }
+            if (!hasInPlanStaff(tmpInspectionPlanDto, staffs)) {
+                unitInfo = new JSONObject();
+                unitInfo.put("id", "s_" + tmpInspectionPlanDto.getStaffId());
+                unitInfo.put("staffId", tmpInspectionPlanDto.getStaffId());
+                unitInfo.put("inspectionPlanId",plan.getString("inspectionPlanId"));
+                unitInfo.put("communityId", plan.getString("communityId"));
+                unitInfo.put("text", tmpInspectionPlanDto.getStaffName());
+                unitInfo.put("icon", "/img/unit.png");
+                staffs.add(unitInfo);
+            }
+        }
+
+    }
+
+    private boolean hasInPlanStaff(InspectionPlanDto inspectionPlanDto, JSONArray staffs) {
+        JSONObject staff = null;
+        for (int cIndex = 0; cIndex < staffs.size(); cIndex++) {
+            staff = staffs.getJSONObject(cIndex);
+            if (!staff.containsKey("staffId")) {
+                continue;
+            }
+            if (StringUtil.isEmpty(staff.getString("staffId"))) {
+                continue;
+            }
+            if (staff.getString("staffId").equals(inspectionPlanDto.getStaffId())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    private boolean hasInInspectionPlan(InspectionPlanDto tmpInspectionPlanDto, JSONArray parkings) {
+        JSONObject plan = null;
+        for (int cIndex = 0; cIndex < parkings.size(); cIndex++) {
+            plan = parkings.getJSONObject(cIndex);
+            if (!plan.containsKey("inspectionPlanId")) {
+                continue;
+            }
+            if (StringUtil.isEmpty(plan.getString("inspectionPlanId"))) {
+                continue;
+            }
+            if (plan.getString("inspectionPlanId").equals(tmpInspectionPlanDto.getInspectionPlanId())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    private boolean hasInCommunity(InspectionPlanDto tmpInspectionPlanDto, JSONArray communitys) {
+        JSONObject community = null;
+        for (int cIndex = 0; cIndex < communitys.size(); cIndex++) {
+            community = communitys.getJSONObject(cIndex);
+            if (!community.containsKey("communityId")) {
+                continue;
+            }
+            if (StringUtil.isEmpty(community.getString("communityId"))) {
+                continue;
+            }
+            if (community.getString("communityId").equals(tmpInspectionPlanDto.getCommunityId())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+}

+ 2 - 0
service-report/src/main/java/com/java110/report/dao/IReportCommunityServiceDao.java

@@ -118,4 +118,6 @@ public interface IReportCommunityServiceDao {
     List<Map> queryCommunityParkingTree(Map info);
 
     List<Map> queryCommunityRepairTree(Map info);
+
+    List<Map> queryCommunityInspectionTree(Map info);
 }

+ 9 - 0
service-report/src/main/java/com/java110/report/dao/impl/ReportCommunityServiceDaoImpl.java

@@ -155,6 +155,15 @@ public class ReportCommunityServiceDaoImpl extends BaseServiceDao implements IRe
         return infos;
     }
 
+    @Override
+    public List<Map> queryCommunityInspectionTree(Map info) {
+        logger.debug("查询queryCommunityInspectionTree信息 入参 info : {}", JSONObject.toJSONString(info));
+
+        List<Map> infos = sqlSessionTemplate.selectList("reportCommunityServiceDaoImpl.queryCommunityInspectionTree", info);
+
+        return infos;
+    }
+
     @Override
     public int queryHisOwnerCarCount(Map info) {
         logger.debug("查询车辆管理数据 入参 info : {}", info);

+ 11 - 0
service-report/src/main/java/com/java110/report/smo/impl/ReportCommunityInnerServiceSMOImpl.java

@@ -4,6 +4,7 @@ package com.java110.report.smo.impl;
 import com.java110.core.base.smo.BaseServiceSMO;
 import com.java110.dto.PageDto;
 import com.java110.dto.fee.FeeConfigDto;
+import com.java110.dto.inspection.InspectionPlanDto;
 import com.java110.dto.parking.ParkingAreaDto;
 import com.java110.dto.repair.RepairSettingDto;
 import com.java110.dto.room.RoomDto;
@@ -101,6 +102,16 @@ public class ReportCommunityInnerServiceSMOImpl extends BaseServiceSMO implement
         return repairSettingDtos;
     }
 
+    @Override
+    public List<InspectionPlanDto> queryCommunityInspectionTree(@RequestBody InspectionPlanDto inspectionPlanDto) {
+        //校验是否传了 分页信息
+        List<InspectionPlanDto> inspectionPlanDtos = BeanConvertUtil.covertBeanList(
+                reportCommunityServiceDaoImpl.queryCommunityInspectionTree(BeanConvertUtil.beanCovertMap(inspectionPlanDto)),
+                InspectionPlanDto.class);
+
+        return inspectionPlanDtos;
+    }
+
     @Override
     public int queryHisOwnerCarCount(@RequestBody OwnerCarDto ownerCarDto) {
         return reportCommunityServiceDaoImpl.queryHisOwnerCarCount(BeanConvertUtil.beanCovertMap(ownerCarDto));