|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|