wangbo 3 years ago
parent
commit
c729adc634

+ 1 - 1
operation_manager/src/main/java/com/huaxu/order/controller/WorkOrderManageController.java

@@ -387,7 +387,7 @@ public class WorkOrderManageController {
      * @return
      */
     @GetMapping("/event/list")
-    @ApiOperation(value = "查询事件隐患/所有工单")
+    @ApiOperation(value = "App事件列表")
     public AjaxMessage<Pagination<WorkOrderManageDto>> selectEventList(
             @ApiParam(value = "页数", required = true)@RequestParam Integer pageNum,
             @ApiParam(value = "条数", required = true)@RequestParam Integer pageSize){

+ 51 - 0
operation_manager/src/main/java/com/huaxu/order/controller/WorkOrderStatisticsController.java

@@ -1,4 +1,55 @@
 package com.huaxu.order.controller;
 
+import com.huaxu.model.AjaxMessage;
+import com.huaxu.model.LoginUser;
+import com.huaxu.model.ResultStatus;
+import com.huaxu.order.dto.WorkOrderManageDto;
+import com.huaxu.order.service.WorkOrderManageService;
+import com.huaxu.util.UserUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/order/workOrderStatistics/")
+@Api(tags = "工单统计")
 public class WorkOrderStatisticsController {
+
+    @Autowired
+    WorkOrderManageService workOrderManageService;
+
+    @RequestMapping(value = "completionStatistics", method = RequestMethod.GET)
+    @ApiOperation(value = "工单完成情况统计()")
+    public AjaxMessage<Map<String,Object>> completionStatistics(
+            @ApiParam(value="统计类型:0-按月统计,1-按年统计",required =true) @RequestParam(required = true) int type,
+            @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy)", required = true) @RequestParam(required = true) String startDate) {
+        if(type==0){
+            startDate = String.format("%s-01",startDate);
+        }
+        else if(type==1){
+            startDate = String.format("%s-01-01",startDate);
+        }
+        //根据用户编号,获取用户的权限
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
+        workOrderManageDto.setStartDate(startDate);
+        workOrderManageDto.setOrderStatus(type);
+        workOrderManageDto.setProgramItems(loginUser.getProgramItemList());
+        workOrderManageDto.setUserType(loginUser.getType());
+        //1是公司,2是公司及以下,3部门,4部门及以下,5自定义
+        workOrderManageDto.setPermissonType(loginUser.getPermissonType());
+        Map<String,Object> result=workOrderManageService.workOrderStatistics(workOrderManageDto);
+        return new AjaxMessage<>(ResultStatus.OK,  result);
+    }
+
 }

+ 8 - 3
operation_manager/src/main/resources/mapper/order/WorkOrderManageMapper.xml

@@ -863,7 +863,6 @@
     </where>
   </select>
 
-
   <!--工单完成情况统计-->
   <select id="workOrderStatistics" resultType="map">
     select  total '工单总数', finished '工单完成数', finished/total '工单完成率' from
@@ -872,8 +871,14 @@
       from sc_work_order_manage t1
       <where>
         t1.order_status != 0
-        and t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%c-%d')
-        and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%c-%d')
+        <if test="order.statsType == 0">
+          and t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%c-%d')
+          and t1.date_create &lt; DATE_ADD(date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%c-%d'),INTERVAL 1 MONTH)
+        </if>
+        <if test="order.statsType == 1">
+          and t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%c-%d')
+          and t1.date_create &lt; DATE_ADD(date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%c-%d'),INTERVAL 1 YEAR)
+        </if>
         <if test="order.tenantId != null and order.tenantId != ''">
           and t1.tenant_id = #{order.tenantId}
         </if>