shudonghui hai 1 ano
pai
achega
cee9117e1a

+ 13 - 4
sop-api/src/main/java/com/qmth/sop/server/api/SopScheduleController.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -54,7 +55,7 @@ public class SopScheduleController {
      * 5.项目进度阶段总体分布对比
      * 服务单元下所有项目的进度阶段总体分布对比,各阶段统计解释同上。
      */
-   
+    @Aac(auth = false)
     @ApiOperation(value = "项目阶段分布")
     @RequestMapping(value = "/progress", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "项目阶段分布", response = Map.class)})
@@ -67,7 +68,7 @@ public class SopScheduleController {
     /*
     SOP明细
      */
-   
+
     @ApiOperation(value = "SOP明细")
     @RequestMapping(value = "/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "SOP明细", response = Map.class)})
@@ -76,9 +77,17 @@ public class SopScheduleController {
                          @ApiParam(value = "供应商") @RequestParam(required = false) Long supplierId,
                          @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                          @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
-        IPage<Map<String,Object>> resultIPage = sopScheduleService.detail(new Page<>(pageNumber, pageSize),serviceId, regionId, supplierId);
+        IPage<Map<String, Object>> resultIPage = sopScheduleService.detail(new Page<>(pageNumber, pageSize), serviceId, regionId, supplierId);
         return ResultUtil.ok(resultIPage);
     }
 
+    //项目燃尽图
+    @ApiOperation(value = "项目燃尽图")
+    @RequestMapping(value = "/projectProgress", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "项目燃尽图", response = Map.class)})
+    public Result projectProgress(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceId) {
+        Map<String, List<Map<String, Object>>> list = sopScheduleService.projectProgress(serviceId);
+        return ResultUtil.ok(list);
+    }
 
-}
+}

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/SopScheduleMapper.java

@@ -22,4 +22,7 @@ public interface SopScheduleMapper extends BaseMapper<TBSopInfo> {
     List<Map<String, Object>> progress(@Param("serviceId") Long serviceId);
 
     <T> IPage<Map<String,Object>> detail(Page<T> tPage, @Param("serviceId")Long serviceId, @Param("regionId") Long regionId, @Param("supplierId") Long supplierId);
+
+
+    List<Map<String, Object>> actualProgress(@Param("serviceId") Long serviceId);
 }

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SopScheduleService.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.entity.TBSopInfo;
 import com.qmth.sop.common.enums.SopAnalyseGroupEnum;
 
+import java.util.List;
 import java.util.Map;
 
 public interface SopScheduleService extends IService<TBSopInfo> {
@@ -14,4 +15,6 @@ public interface SopScheduleService extends IService<TBSopInfo> {
     Map<String, Map<String, Object>> progress(Long serviceId, SopAnalyseGroupEnum group);
 
     <T> IPage<Map<String,Object>> detail(Page<T> tPage, Long serviceId, Long regionId, Long supplierId);
+
+    Map<String, List<Map<String, Object>>> projectProgress(Long serviceId);
 }

+ 81 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SopScheduleServiceImpl.java

@@ -3,17 +3,34 @@ package com.qmth.sop.business.service.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.params.FormWidgetMetadataParam;
+import com.qmth.sop.business.bean.params.SopInfoListParam;
+import com.qmth.sop.business.bean.result.FormWidgetMetadataResult;
 import com.qmth.sop.business.entity.TBSopInfo;
 import com.qmth.sop.business.mapper.SopScheduleMapper;
+import com.qmth.sop.business.mapper.TBSopInfoMapper;
 import com.qmth.sop.business.service.SopScheduleService;
+import com.qmth.sop.business.service.TDFormWidgetMetadataService;
+import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.SopAnalyseGroupEnum;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
+import com.qmth.sop.common.util.DateDisposeUtils;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
+import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
 public class SopScheduleServiceImpl extends ServiceImpl<SopScheduleMapper, TBSopInfo> implements SopScheduleService {
+    @Resource
+    TBSopInfoMapper tbSopInfoMapper;
+
+    @Resource
+    TDFormWidgetMetadataService tdFormWidgetMetadataService;
+
     /**
      * * ①准备:扫描前的准备阶段;
      * * ②扫描:扫描仪配置产出物提交,到扫描收尾产出物提交;
@@ -50,4 +67,68 @@ public class SopScheduleServiceImpl extends ServiceImpl<SopScheduleMapper, TBSop
         return this.baseMapper.detail(tPage, serviceId, regionId, supplierId);
     }
 
+    @Override
+    public Map<String, List<Map<String, Object>>> projectProgress(Long serviceId) {
+        Map<String, List<Map<String, Object>>> result = new HashMap<>();
+        TFCustomTypeEnum[] types = {TFCustomTypeEnum.OFFICE_SOP_FLOW, TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW};
+        List<Map<String, Object>> tempList = new ArrayList<>();
+        for (TFCustomTypeEnum type : types) {
+            List<FormWidgetMetadataResult> formWidgetMetadataResults = tdFormWidgetMetadataService.selectAll(type, 1);
+            String fieldId = formWidgetMetadataResults.stream().filter(e -> e.getFieldTitle().equals("现场标准服务周期(人天)")).findFirst().get().getFieldId();
+            SopInfoListParam sopInfoListParam = getSopInfoListParam(serviceId, type, fieldId);
+            String tableName = sopInfoListParam.getType().getTableName() + "_" + sopInfoListParam.getVersion();
+            //显示字段
+            String fieldName = null;
+            StringJoiner stringJoinerView = new StringJoiner(",");
+            if (!CollectionUtils.isEmpty(sopInfoListParam.getFormWidgetMetadataViewList())) {
+                for (FormWidgetMetadataParam f : sopInfoListParam.getFormWidgetMetadataViewList()) {
+                    stringJoinerView.add(f.getFieldId());
+                }
+                fieldName = stringJoinerView.toString();
+            }
+            List<Map> list = tbSopInfoMapper.list(new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()), Objects.nonNull(sopInfoListParam.getType()) ? sopInfoListParam.getType().name() : null, sopInfoListParam.getServiceId(), tableName, fieldName, null, null, null).getRecords();
+
+
+            list.forEach(l -> {
+                List<String> daysBetween = DateDisposeUtils.getDaysBetween((Long) l.get("examStartTime"), (Long) l.get("examEndTime"), SystemConstant.DEFAULT_DATE_YMD_PATTERN);
+                daysBetween.forEach(d -> {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("datetime", d);
+                    map.put("count", l.get(fieldId));
+                    tempList.add(map);
+                });
+            });
+        }
+        //日期相同的合并 计算count之和
+        List<Map<String, Object>> plan = new ArrayList<>();
+        tempList.stream().collect(Collectors.groupingBy(map -> map.get("datetime"))).forEach((k, v) -> {
+            Map<String, Object> map = new HashMap<>();
+            map.put("datetime", k);
+            map.put("count", v.stream().mapToInt(m -> Integer.parseInt(m.get("count").toString())).sum());
+            plan.add(map);
+        });
+
+
+
+        result.put("plan", plan);
+        result.put("actual", this.baseMapper.actualProgress(serviceId));
+        return result;
+    }
+
+    @NotNull
+    private static SopInfoListParam getSopInfoListParam(Long serviceId, TFCustomTypeEnum type, String fieldId) {
+        SopInfoListParam sopInfoListParam = new SopInfoListParam();
+        sopInfoListParam.setPageNumber(1);
+        sopInfoListParam.setPageSize(Integer.MAX_VALUE);
+        sopInfoListParam.setServiceId(serviceId);
+        List<FormWidgetMetadataParam> formWidgetMetadataViewList = new ArrayList<>();
+        FormWidgetMetadataParam formWidgetMetadataParam = new FormWidgetMetadataParam();
+        formWidgetMetadataParam.setFieldId(fieldId);
+        formWidgetMetadataViewList.add(formWidgetMetadataParam);
+        sopInfoListParam.setFormWidgetMetadataViewList(formWidgetMetadataViewList);
+        sopInfoListParam.setFormWidgetMetadataConditionList(new ArrayList<>());
+        sopInfoListParam.setType(type);
+        return sopInfoListParam;
+    }
+
 }

+ 23 - 1
sop-business/src/main/resources/mapper/SopScheduleMapper.xml

@@ -30,7 +30,7 @@
         <where>
 
             <if test="serviceId != null and serviceId != ''">
-                and  tbsi.service_id= #{serviceId}
+                and tbsi.service_id= #{serviceId}
             </if>
 
         </where>
@@ -100,4 +100,26 @@
             </if>
         </where>
     </select>
+
+    <select id="actualProgress" resultType="java.util.Map">
+        SELECT
+        DATE_FORMAT(
+        FROM_UNIXTIME(
+        ( CASE WHEN d.sign_in_time IS NOT NULL THEN d.sign_in_time WHEN d.sign_out_time IS NOT NULL THEN d.sign_out_time
+        ELSE NULL END )/ 1000
+        ),
+        '%Y-%m-%d'
+        ) datetime,
+        count(DISTINCT d.user_id ) count
+        FROM
+        t_b_ding d
+        <where>
+
+            <if test="serviceId != null and serviceId != ''">
+                and d.service_id= #{serviceId}
+            </if>
+        </where>
+        GROUP BY
+        datetime
+    </select>
 </mapper>