瀏覽代碼

资源保障报表

wangliang 9 月之前
父節點
當前提交
8f2ad8cb18

+ 15 - 3
sop-api/src/main/java/com/qmth/sop/server/api/ResourceSecurityReportController.java

@@ -1,5 +1,6 @@
 package com.qmth.sop.server.api;
 
+import com.google.common.collect.ImmutableMap;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.report.DingExceptionCountReportBean;
 import com.qmth.sop.business.bean.report.SupplierCountReportBean;
@@ -14,12 +15,17 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 @Api(tags = "资源保障报表Controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_RESOURCE_SECURITY)
 public class ResourceSecurityReportController {
 
+    public static final String SUM = "sum";
+
+    public static final String RECORDS = "records";
+
     @Resource
     ResourceSecurityReportService resourceSecurityReportService;
 
@@ -28,7 +34,10 @@ public class ResourceSecurityReportController {
     @ApiResponses({ @ApiResponse(code = 200, message = "供应商供货数量分布报表", response = SupplierCountReportBean.class) })
     public Result deviceSupplierCountReport(
             @ApiParam(value = "设备商供货数量分布报表", required = true) @RequestParam Long serviceId) {
-        return ResultUtil.ok(resourceSecurityReportService.deviceSupplierCountReport(serviceId));
+        List<SupplierCountReportBean> supplierCountReportBeanList = resourceSecurityReportService.deviceSupplierCountReport(
+                serviceId);
+        Integer sum = supplierCountReportBeanList.stream().mapToInt(s -> s.getCount()).sum();
+        return ResultUtil.ok(ImmutableMap.of(SUM, sum, RECORDS, supplierCountReportBeanList));
     }
 
     @ApiOperation(value = "人力数量分布")
@@ -36,7 +45,10 @@ public class ResourceSecurityReportController {
     @ApiResponses({ @ApiResponse(code = 200, message = "供应商供货数量分布报表", response = SupplierCountReportBean.class) })
     public Result humanSupplierCountReport(
             @ApiParam(value = "人力数量分布报表", required = true) @RequestParam Long serviceId) {
-        return ResultUtil.ok(resourceSecurityReportService.humanSupplierCountReport(serviceId));
+        List<SupplierCountReportBean> supplierCountReportBeanList = resourceSecurityReportService.humanSupplierCountReport(
+                serviceId);
+        Integer sum = supplierCountReportBeanList.stream().mapToInt(s -> s.getCount()).sum();
+        return ResultUtil.ok(ImmutableMap.of(SUM, sum, RECORDS, supplierCountReportBeanList));
     }
 
     @ApiOperation(value = "大区考勤异常数统计")
@@ -52,6 +64,6 @@ public class ResourceSecurityReportController {
     @ApiResponses({ @ApiResponse(code = 200, message = "考勤异常报表", response = DingExceptionCountReportBean.class) })
     public Result humanDingExceptionCountReport(
             @ApiParam(value = "人力供应商考勤异常数统计报表", required = true) @RequestParam Long serviceId) {
-        return ResultUtil.ok(resourceSecurityReportService.humanSupplierCountReport(serviceId));
+        return ResultUtil.ok(resourceSecurityReportService.humanDingExceptionCountReport(serviceId));
     }
 }

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/ResourceSecurityReportMapper.java

@@ -40,4 +40,12 @@ public interface ResourceSecurityReportMapper extends BaseMapper<TBService> {
      * @return
      */
     List<DingExceptionCountReportBean> areaDingExceptionCountReport(@Param("serviceId") Long serviceId);
+
+    /**
+     * 人力供应商考勤异常数统计
+     *
+     * @param serviceId
+     * @return
+     */
+    List<DingExceptionCountReportBean> humanDingExceptionCountReport(@Param("serviceId") Long serviceId);
 }

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/service/ResourceSecurityReportService.java

@@ -39,4 +39,12 @@ public interface ResourceSecurityReportService extends IService<TBService> {
      * @return
      */
     List<DingExceptionCountReportBean> areaDingExceptionCountReport(Long serviceId);
+
+    /**
+     * 人力供应商考勤异常数统计
+     *
+     * @param serviceId
+     * @return
+     */
+    List<DingExceptionCountReportBean> humanDingExceptionCountReport(Long serviceId);
 }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/ResourceSecurityReportServiceImpl.java

@@ -53,4 +53,15 @@ public class ResourceSecurityReportServiceImpl extends ServiceImpl<ResourceSecur
     public List<DingExceptionCountReportBean> areaDingExceptionCountReport(Long serviceId) {
         return this.baseMapper.areaDingExceptionCountReport(serviceId);
     }
+
+    /**
+     * 人力供应商考勤异常数统计
+     *
+     * @param serviceId
+     * @return
+     */
+    @Override
+    public List<DingExceptionCountReportBean> humanDingExceptionCountReport(Long serviceId) {
+        return this.baseMapper.humanDingExceptionCountReport(serviceId);
+    }
 }

+ 5 - 2
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -371,7 +371,7 @@ UPDATE sys_privilege
 SET name='项目进度分析', url='sopSchedule', `type`='MENU', parent_id=1100, `sequence`=2, property=NULL, related=NULL, enable=1, default_auth=0, front_display=1
 WHERE id=1104;
 UPDATE sys_privilege
-SET name='资源保障分析', url='deviceMonitor', `type`='MENU', parent_id=1100, `sequence`=5, property=NULL, related='1107,1108,1109', enable=1, default_auth=0, front_display=1
+SET name='资源保障分析', url='deviceMonitor', `type`='MENU', parent_id=1100, `sequence`=5, property=NULL, related='1107,1108,1109,1110', enable=1, default_auth=0, front_display=1
 WHERE id=1105;
 UPDATE sys_privilege
 SET name='质量监控分析', url='qualityAnalyse', `type`='MENU', parent_id=1100, `sequence`=6, property=NULL, related=NULL, enable=1, default_auth=0, front_display=1
@@ -385,4 +385,7 @@ INSERT INTO sys_privilege
 VALUES(1108, '人力数量分布接口', '/api/admin/resource/security/human_supplier_count/report', 'URL', 1105, 1, 'AUTH', NULL, 1, 1, 1);
 INSERT INTO sys_privilege
 (id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
-VALUES(1109, '大区考勤异常数统计接口', '/api/admin/resource/security/area_ding_exception_count/report', 'URL', 1105, 1, 'AUTH', NULL, 1, 1, 1);
+VALUES(1109, '大区考勤异常数统计接口', '/api/admin/resource/security/area_ding_exception_count/report', 'URL', 1105, 1, 'AUTH', NULL, 1, 1, 1);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(1110, '人力供应商考勤异常数统计', '/api/admin/resource/security/human_ding_exception_count/report', 'URL', 1105, 1, 'AUTH', NULL, 1, 1, 1);

+ 18 - 0
sop-business/src/main/resources/mapper/ResourceSecurityReportMapper.xml

@@ -47,4 +47,22 @@
         group by su.real_name) t where t.count > 0
         order by t.areaManagerName
     </select>
+
+    <select id="humanDingExceptionCountReport" resultType="com.qmth.sop.business.bean.report.DingExceptionCountReportBean">
+        select * from(select distinct ss.name as humanSupplierName,sum(case when tbd.sign_in_time is null or tbd.sign_out_time is null then 1 else 0 end) as count
+          from t_b_service tbs
+                   join t_b_crm tbc on tbc.service_id = tbs.id
+                   join t_b_sop_info tbsi on tbsi.crm_no = tbc.crm_no
+                   join t_f_custom_flow_entity tfcfe on tfcfe.code = tbsi.sop_no
+                   join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
+                   join t_b_ding tbd on tbd.ding_sop_no = tbsi.sop_no
+                   join sys_user su on su.id = tbd.user_id
+                   join t_b_user_archives_supplier tbuas on tbuas.user_archives_id = tbd.user_archives_id
+                   join sys_supplier ss on ss.id = tbuas.supplier_id
+          where tbs.id = #{serviceId}
+            and tbs.status <![CDATA[ <> ]]> 'CANCEL'
+            and tffa.status <![CDATA[ <> ]]> 'END'
+          group by ss.name) t where t.count > 0
+        order by t.humanSupplierName
+    </select>
 </mapper>