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

加入员工巡检情况统计功能

wuxw лет назад: 3
Родитель
Сommit
8f24e10562

+ 1 - 0
java110-bean/src/main/java/com/java110/dto/inspectionPlan/InspectionPlanStaffDto.java

@@ -28,6 +28,7 @@ public class InspectionPlanStaffDto extends PageDto implements Serializable {
     private String statusCd = "0";
 
 
+
     public String getIpStaffId() {
         return ipStaffId;
     }

+ 74 - 0
java110-bean/src/main/java/com/java110/dto/inspectionPlan/InspectionStaffDto.java

@@ -0,0 +1,74 @@
+package com.java110.dto.inspectionPlan;
+
+import java.io.Serializable;
+
+/**
+ * 员工巡检情况统计
+ * <p>
+ * add by wuxw 2022-11-15
+ */
+public class InspectionStaffDto implements Serializable {
+    private String staffId;
+    private String staffName;
+    private String finishCount;
+    private String waitCount;
+    private String communityId;
+    private String queryTime;
+    private String state;
+
+    public String getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(String staffId) {
+        this.staffId = staffId;
+    }
+
+    public String getStaffName() {
+        return staffName;
+    }
+
+    public void setStaffName(String staffName) {
+        this.staffName = staffName;
+    }
+
+    public String getFinishCount() {
+        return finishCount;
+    }
+
+    public void setFinishCount(String finishCount) {
+        this.finishCount = finishCount;
+    }
+
+    public String getWaitCount() {
+        return waitCount;
+    }
+
+    public void setWaitCount(String waitCount) {
+        this.waitCount = waitCount;
+    }
+
+    public String getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(String communityId) {
+        this.communityId = communityId;
+    }
+
+    public String getQueryTime() {
+        return queryTime;
+    }
+
+    public void setQueryTime(String queryTime) {
+        this.queryTime = queryTime;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+}

+ 33 - 0
java110-db/src/main/resources/mapper/community/InspectionPlanStaffV1ServiceDaoImplMapper.xml

@@ -113,4 +113,37 @@
 
     </select>
 
+    <!-- 查询员工巡检情况 -->
+    <select id="queryStaffInspectionReport" parameterType="Map" resultType="Map">
+        select
+        t.staff_name staffName,t.staff_id staffId,
+        (select count(1) from inspection_task it
+        INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'
+        where  it.plan_user_id = t.staff_id
+        and itd.act_user_id is not null
+        and DATE_FORMAT(it.create_time,'%Y-%m-%d') = #{queryTime}
+        ) finishCount,
+        (select count(1) from inspection_task it
+        INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'
+        where it.plan_user_id = t.staff_id
+        and itd.act_user_id is null
+        and DATE_FORMAT(it.create_time,'%Y-%m-%d') = #{queryTime}
+        ) waitCount,
+        (select itd.description from inspection_task it
+        INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'
+        where  it.plan_user_id = t.staff_id
+        and itd.act_user_id is not null
+        and DATE_FORMAT(it.create_time,'%Y-%m-%d') = #{queryTime}
+        limit 1
+        ) state
+        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 inspection_route_point_rel irpr on ip.inspection_route_id = irpr.inspection_route_id and irpr.status_cd= '0'
+        left join inspection_point ipo on irpr.inspection_id = ipo.inspection_id and ipo.status_cd = '0'
+        where 1=1
+        and t.status_cd = '0'
+        and t.community_id = #{communityId}
+        GROUP BY  t.staff_name ,t.staff_id
+    </select>
+
 </mapper>

+ 9 - 0
java110-interface/src/main/java/com/java110/intf/community/IInspectionPlanStaffV1InnerServiceSMO.java

@@ -17,6 +17,7 @@ package com.java110.intf.community;
 
 import com.java110.config.feign.FeignConfiguration;
 import com.java110.dto.inspectionPlan.InspectionPlanStaffDto;
+import com.java110.dto.inspectionPlan.InspectionStaffDto;
 import com.java110.po.inspection.InspectionPlanStaffPo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -64,4 +65,12 @@ public interface IInspectionPlanStaffV1InnerServiceSMO {
      */
     @RequestMapping(value = "/queryInspectionPlanStaffsCount", method = RequestMethod.POST)
     int queryInspectionPlanStaffsCount(@RequestBody InspectionPlanStaffDto inspectionPlanStaffDto);
+
+    /**
+     * 查询员工的巡检情况
+     * @param inspectionStaffDto
+     * @return
+     */
+    @RequestMapping(value = "/queryStaffInspectionReport", method = RequestMethod.POST)
+    List<InspectionStaffDto> queryStaffInspectionReport(@RequestBody InspectionStaffDto inspectionStaffDto);
 }

+ 76 - 0
service-community/src/main/java/com/java110/community/cmd/inspection/QueryReportStaffInspectionCmd.java

@@ -0,0 +1,76 @@
+package com.java110.community.cmd.inspection;
+
+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.doc.annotation.*;
+import com.java110.dto.inspectionPlan.InspectionStaffDto;
+import com.java110.intf.community.IInspectionPlanStaffV1InnerServiceSMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 员工巡检情况统计
+ *
+ *
+ */
+
+@Java110CmdDoc(title = "员工巡检情况统计",
+        description = "物业手机端员工巡检情况统计,方便老板查看",
+        httpMethod = "get",
+        url = "http://{ip}:{port}/app/inspection.queryReportStaffInspection",
+        resource = "communityDoc",
+        author = "吴学文",
+        serviceCode = "inspection.queryReportStaffInspection"
+)
+
+@Java110ParamsDoc(params = {
+        @Java110ParamDoc(name = "communityId", length = 30, remark = "小区信息"),
+        @Java110ParamDoc(name = "queryTime", length = 30, remark = "查询日期 YYYY-MM-DD"),
+})
+
+@Java110ResponseDoc(
+        params = {
+                @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "返回编号,0 成功 其他失败"),
+                @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "成功", remark = "描述"),
+                @Java110ParamDoc(name = "data", type = "Object", remark = "有效数据"),
+                @Java110ParamDoc(parentNodeName = "data",name = "userId", type = "String", remark = "用户ID"),
+                @Java110ParamDoc(parentNodeName = "data",name = "token", type = "String", remark = "临时票据"),
+        }
+)
+
+@Java110ExampleDoc(
+        reqBody="http://{ip}:{port}/app/inspection.queryReportStaffInspection?communityId=12323&queryTime=2022-11-11",
+        resBody="{'code':0,'msg':'成功','data':{'staffName':'123123','finishCount':'123213','waitCount':123123}}"
+)
+
+@Java110Cmd(serviceCode = "inspection.queryReportStaffInspection")
+public class QueryReportStaffInspectionCmd extends Cmd{
+
+    @Autowired
+    private IInspectionPlanStaffV1InnerServiceSMO inspectionPlanStaffV1InnerServiceSMOImpl;
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        Assert.hasKeyAndValue(reqJson,"communityId","未包含小区信息");
+        Assert.hasKeyAndValue(reqJson,"queryTime","未包含查询日期");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+
+        InspectionStaffDto inspectionStaffDto = BeanConvertUtil.covertBean(reqJson, InspectionStaffDto.class);
+
+        List<InspectionStaffDto> inspectionStaffDtos = inspectionPlanStaffV1InnerServiceSMOImpl.queryStaffInspectionReport(inspectionStaffDto);
+
+        context.setResponseEntity(ResultVo.createResponseEntity(inspectionStaffDtos));
+    }
+}

+ 6 - 0
service-community/src/main/java/com/java110/community/dao/IInspectionPlanStaffV1ServiceDao.java

@@ -74,4 +74,10 @@ public interface IInspectionPlanStaffV1ServiceDao {
      */
     int queryInspectionPlanStaffsCount(Map info);
 
+    /**
+     * 查询员工 巡检情况
+     * @param info
+     * @return
+     */
+    List<Map> queryStaffInspectionReport(Map info);
 }

+ 13 - 0
service-community/src/main/java/com/java110/community/dao/impl/InspectionPlanStaffV1ServiceDaoImpl.java

@@ -108,5 +108,18 @@ public class InspectionPlanStaffV1ServiceDaoImpl extends BaseServiceDao implemen
         return Integer.parseInt(businessInspectionPlanStaffInfos.get(0).get("count").toString());
     }
 
+    /**
+     * 根据员工查询巡检情况
+     * @param info
+     * @return
+     */
+    @Override
+    public List<Map> queryStaffInspectionReport(Map info) {
+        logger.debug("查询 queryStaffInspectionReport 入参 info : {}",info);
+
+        List<Map> businessInspectionPlanStaffInfos = sqlSessionTemplate.selectList("inspectionPlanStaffV1ServiceDaoImpl.queryStaffInspectionReport",info);
+
+        return businessInspectionPlanStaffInfos;    }
+
 
 }

+ 10 - 0
service-community/src/main/java/com/java110/community/smo/impl/InspectionPlanStaffV1InnerServiceSMOImpl.java

@@ -20,6 +20,7 @@ import com.java110.community.dao.IInspectionPlanStaffV1ServiceDao;
 import com.java110.core.base.smo.BaseServiceSMO;
 import com.java110.dto.PageDto;
 import com.java110.dto.inspectionPlan.InspectionPlanStaffDto;
+import com.java110.dto.inspectionPlan.InspectionStaffDto;
 import com.java110.intf.community.IInspectionPlanStaffV1InnerServiceSMO;
 import com.java110.po.inspection.InspectionPlanStaffPo;
 import com.java110.utils.util.BeanConvertUtil;
@@ -85,4 +86,13 @@ public class InspectionPlanStaffV1InnerServiceSMOImpl extends BaseServiceSMO imp
         return inspectionPlanStaffV1ServiceDaoImpl.queryInspectionPlanStaffsCount(BeanConvertUtil.beanCovertMap(inspectionPlanStaffDto));
     }
 
+    @Override
+    public List<InspectionStaffDto> queryStaffInspectionReport(@RequestBody InspectionStaffDto inspectionStaffDto) {
+        List<InspectionStaffDto> inspectionStaffDtos = BeanConvertUtil.covertBeanList(
+                inspectionPlanStaffV1ServiceDaoImpl.queryStaffInspectionReport(
+                        BeanConvertUtil.beanCovertMap(inspectionStaffDto)), InspectionStaffDto.class);
+
+        return inspectionStaffDtos;
+    }
+
 }

+ 22 - 24
service-report/src/main/java/com/java110/report/bmo/customReport/InspectionData.java

@@ -72,39 +72,37 @@ public class InspectionData implements ReportExecute {
         JSONObject paramOut = new JSONObject();
 
         List sqlParams = new ArrayList();
-        String sql = "select t.inspection_name '巡检点',t.point_obj_name '位置',ips.staff_name '员工',\n" +
-                "(select count(1) from inspection_task it \n" +
+        String sql = "select t.inspection_name '巡检点',\n" +
+                "t.point_obj_name '位置',\n" +
+                "ips.staff_name '员工',\n" +
+                "(select count(1) from inspection_task it\n" +
                 "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
-                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
-                "and itd.inspection_id = t.inspection_id and it.plan_user_id = ips.staff_id\n" +
+                "where  itd.inspection_id = t.inspection_id and it.plan_user_id = ips.staff_id\n" +
                 "and itd.act_user_id is not null\n" +
                 "and it.create_time > ?\n" +
                 "and it.create_time < ?\n" +
                 ") '已巡检',\n" +
-                "(select count(1) from inspection_task it \n" +
+                "(select count(1) from inspection_task it\n" +
                 "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
-                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
-                "and itd.inspection_id = t.inspection_id and it.plan_user_id = ips.staff_id\n" +
+                "where  itd.inspection_id = t.inspection_id and it.plan_user_id = ips.staff_id\n" +
                 "and itd.act_user_id is null\n" +
                 "and it.create_time > ?\n" +
                 "and it.create_time < ?\n" +
                 ") '未巡检',\n" +
-                "(select itd.description from inspection_task it \n" +
+                "(select itd.description from inspection_task it\n" +
                 "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
-                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
-                "and itd.inspection_id = t.inspection_id and it.plan_user_id = ips.staff_id\n" +
-                "and itd.act_user_id is not null\n" +
-                "and it.create_time > ?\n" +
-                "and it.create_time < ?\n" +
-                "limit 1\n" +
-                ") '状态'\n" +
-                " from inspection_point t \n" +
-                "left join inspection_route_point_rel irpr on t.inspection_id = irpr.inspection_id and irpr.status_cd = '0'\n" +
-                "left join inspection_plan ip on ip.inspection_route_id = irpr.inspection_route_id and ip.status_cd = '0'\n" +
-                "left join inspection_plan_staff ips on ip.inspection_plan_id = ips.inspection_plan_id and ips.status_cd = '0'\n" +
-                "\n" +
-                "where ips.staff_name is not null\n" +
-                "and t.status_cd = '0'\n" ;
+                "where  itd.inspection_id = t.inspection_id and it.plan_user_id = ips.staff_id\n" +
+                " and itd.act_user_id is not null\n" +
+                " and it.create_time > ?\n" +
+                " and it.create_time < ?\n" +
+                " limit 1\n" +
+                " ) '状态'\n" +
+                "  from inspection_point t\n" +
+                " left join inspection_route_point_rel irpr on t.inspection_id = irpr.inspection_id and irpr.status_cd = '0'\n" +
+                " left join inspection_plan ip on ip.inspection_route_id = irpr.inspection_route_id and ip.status_cd = '0'\n" +
+                " left join inspection_plan_staff ips on ip.inspection_plan_id = ips.inspection_plan_id and ips.status_cd = '0'\n" +
+                " where ips.staff_name is not null\n" +
+                " and t.status_cd = '0'\n" ;
         if (params.containsKey("startTime") && !StringUtils.isEmpty(params.getString("startTime"))) {
             sqlParams.add(params.get("startTime"));
             sqlParams.add(params.get("endTime"));
@@ -128,7 +126,7 @@ public class InspectionData implements ReportExecute {
             sqlParams.add(params.get("communityId"));
         }
 
-        sql += "group by t.inspection_name,t.point_obj_name,ips.staff_name\n" +
+        sql += "group by t.inspection_name,t.point_obj_name,ips.staff_name,t.inspection_id,ips.staff_id\n" +
                 "order by t.inspection_name";
 
 
@@ -137,7 +135,7 @@ public class InspectionData implements ReportExecute {
         System.out.println("datas="+datas);
 
         if (datas == null || datas.size() < 1) {
-            paramOut.put("toatl",1);
+            paramOut.put("total",1);
             paramOut.put("data",new JSONArray());
             return paramOut.toJSONString();
         }

+ 33 - 35
service-report/src/main/java/com/java110/report/bmo/customReport/InspectionStaffData.java

@@ -31,39 +31,37 @@ public class InspectionStaffData implements ReportExecute {
         JSONObject paramOut = new JSONObject();
 
         List sqlParams = new ArrayList();
-        String sql = "select \n" +
-                "t.staff_name '员工',\n" +
-                "ipo.inspection_name '巡检点',\n" +
-                "(select count(1) from inspection_task it \n" +
-                "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
-                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
-                "and itd.inspection_id = ipo.inspection_id and it.plan_user_id = t.staff_id\n" +
-                "and itd.act_user_id is not null\n" +
-                "and it.create_time > ?\n" +
-                "and it.create_time < ?\n" +
-                ") '已巡检',\n" +
-                "(select count(1) from inspection_task it \n" +
-                "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
-                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
-                "and itd.inspection_id = ipo.inspection_id and it.plan_user_id = t.staff_id\n" +
-                "and itd.act_user_id is null\n" +
-                "and it.create_time > ?\n" +
-                "and it.create_time < ?\n" +
-                ") '未巡检',\n" +
-                "(select itd.description from inspection_task it \n" +
-                "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
-                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
-                "and itd.inspection_id = ipo.inspection_id and it.plan_user_id = t.staff_id\n" +
-                "and itd.act_user_id is not null\n" +
-                "and it.create_time > ?\n" +
-                "and it.create_time < ?\n" +
-                "limit 1\n" +
-                ") '状态'\n" +
-                "from inspection_plan_staff t\n" +
-                "left join inspection_plan ip on t.inspection_plan_id = ip.inspection_plan_id and ip.status_cd = '0'\n" +
-                "left join inspection_route_point_rel irpr on ip.inspection_route_id = irpr.inspection_route_id and irpr.status_cd= '0'\n" +
-                "left join inspection_point ipo on irpr.inspection_id = ipo.inspection_id and ipo.status_cd = '0'\n" +
-                "where 1=1 and t.status_cd = '0'\n";
+        String sql = "select t.staff_name '员工',\n" +
+                " ipo.inspection_name '巡检点',\n" +
+                " (select count(1) from inspection_task it\n" +
+                " INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
+                " where it.plan_user_id = t.staff_id\n" +
+                " and itd.inspection_id = ipo.inspection_id\n" +
+                " and itd.act_user_id is not null\n" +
+                " and it.create_time > ?\n" +
+                " and it.create_time < ?\n" +
+                " ) '已巡检',\n" +
+                " (select count(1) from inspection_task it\n" +
+                " INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
+                " where it.plan_user_id = t.staff_id\n" +
+                "  and itd.inspection_id = ipo.inspection_id\n" +
+                " and itd.act_user_id is null\n" +
+                " and it.create_time > ?\n" +
+                " and it.create_time < ?\n" +
+                " ) '未巡检',\n" +
+                " (select itd.description from inspection_task it\n" +
+                " INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
+                " where  it.plan_user_id = t.staff_id\n" +
+                "  and itd.inspection_id = ipo.inspection_id\n" +
+                " and itd.act_user_id is not null\n" +
+                " and it.create_time > ?\n" +
+                " and it.create_time < ?\n" +
+                " limit 1\n" +
+                " ) '状态'\n" +
+                " from inspection_plan_staff t\n" +
+                " left join inspection_plan ip on t.inspection_plan_id = ip.inspection_plan_id and ip.status_cd = '0'\n" +
+                " left join inspection_route_point_rel irpr on ip.inspection_route_id = irpr.inspection_route_id and irpr.status_cd= '0'\n" +
+                " left join inspection_point ipo on irpr.inspection_id = ipo.inspection_id and ipo.status_cd = '0'\n";
         if (params.containsKey("startTime") && !StringUtils.isEmpty(params.getString("startTime"))) {
             sqlParams.add(params.get("startTime"));
             sqlParams.add(params.get("endTime"));
@@ -87,13 +85,13 @@ public class InspectionStaffData implements ReportExecute {
             sqlParams.add(params.get("communityId"));
         }
 
-        sql += "GROUP BY t.staff_name ,ipo.inspection_name";
+        sql += "GROUP BY t.staff_name ,ipo.inspection_name,t.staff_id,ipo.inspection_id";
 
 
         List datas = queryServiceDAOImpl.executeSql(sql, sqlParams.toArray());
 
         if (datas == null || datas.size() < 1) {
-            paramOut.put("toatl",1);
+            paramOut.put("total",1);
             paramOut.put("data",new JSONArray());
             return paramOut.toJSONString();
         }