|
@@ -1,9 +1,16 @@
|
|
|
package com.platform.service.workplace.impl;
|
|
|
|
|
|
import com.platform.common.constant.CommonConstants;
|
|
|
-import com.platform.common.util.DateUtils;
|
|
|
-import com.platform.common.util.R;
|
|
|
-import com.platform.common.util.SecurityUtils;
|
|
|
+import com.platform.common.util.*;
|
|
|
+import com.platform.dao.dto.repair.RepairApplicationFormDTO;
|
|
|
+import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
+import com.platform.dao.enums.RepairApplicationFormStatusEnum;
|
|
|
+import com.platform.dao.enums.RepairCategoryEnum;
|
|
|
+import com.platform.dao.enums.SbUseType;
|
|
|
+import com.platform.dao.enums.YesNoEnum;
|
|
|
+import com.platform.dao.mapper.sb.SbInfoMapper;
|
|
|
+import com.platform.dao.vo.repair.IndexStatisticVO;
|
|
|
+import com.platform.dao.vo.repair.RepairApplicationFormVO;
|
|
|
import com.platform.service.repair.RepairApplicationFormService;
|
|
|
import com.platform.service.repair.RepairFeeService;
|
|
|
import com.platform.service.sqarepartmanage.SparePartInfoService;
|
|
@@ -12,7 +19,10 @@ import com.platform.service.workplace.IndexService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service("indexService")
|
|
|
public class IndexServiceImpl implements IndexService {
|
|
@@ -24,6 +34,8 @@ public class IndexServiceImpl implements IndexService {
|
|
|
private InStoreFormService inStoreFormService;
|
|
|
@Resource
|
|
|
private SparePartInfoService sparePartInfoService;
|
|
|
+ @Resource
|
|
|
+ private SbInfoMapper sbInfoMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -92,4 +104,108 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
return r;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getStatisticRepairCategory(String positionId) {
|
|
|
+ RepairApplicationFormDTO model = new RepairApplicationFormDTO();
|
|
|
+ model.setPositionId(positionId);
|
|
|
+ List<RepairApplicationFormVO> list = repairApplicationFormService.selectCountByCategory(model);
|
|
|
+ List<RepairApplicationFormVO> result = ListUtils.newArrayList();
|
|
|
+ Map<String, Integer> enums = RepairCategoryEnum.toList();
|
|
|
+ for(Map.Entry<String,Integer> entry : enums.entrySet()){
|
|
|
+ RepairApplicationFormVO vo = new RepairApplicationFormVO();
|
|
|
+ vo.setRepairNum(0);
|
|
|
+ vo.setCategory(entry.getValue());
|
|
|
+ vo.setCategoryName(entry.getKey());
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ if(list != null && list.size() > 0){
|
|
|
+ for(RepairApplicationFormVO tempVO : list){
|
|
|
+ // 拿到数据库中的值和返回集合对比,替换
|
|
|
+ for(RepairApplicationFormVO tempFinal : result){
|
|
|
+ if(tempVO.getCategory().equals(tempFinal.getCategory())){
|
|
|
+ tempFinal.setRepairNum(tempVO.getRepairNum());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new R(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getStatisticData(String positionId) {
|
|
|
+ IndexStatisticVO vo = new IndexStatisticVO();
|
|
|
+ R r = new R();
|
|
|
+ // 维修和完成率
|
|
|
+ RepairApplicationFormDTO repairQuery = new RepairApplicationFormDTO();
|
|
|
+ repairQuery.setPositionId(positionId);
|
|
|
+ Integer repairNum = repairApplicationFormService.countRepair(repairQuery); // 维修总数
|
|
|
+ vo.setRepairNum(new BigDecimal(repairNum));
|
|
|
+ List<Integer> statusList = ListUtils.newArrayList();
|
|
|
+ statusList.add(RepairApplicationFormStatusEnum.FINISHED.getValue());
|
|
|
+ statusList.add(RepairApplicationFormStatusEnum.MM_REPAIR_CLOSE.getValue());
|
|
|
+ repairQuery.setStatusList(statusList);
|
|
|
+ Integer finishNum = repairApplicationFormService.countRepair(repairQuery); // 完成总数
|
|
|
+ vo.setRepairCompleteRate(BigDecimalUtil.divPercent(new BigDecimal(finishNum),vo.getRepairNum(),2));
|
|
|
+ // 特种设备和检定完成率
|
|
|
+ SbInfoDTO sbQuery = new SbInfoDTO();
|
|
|
+ sbQuery.setUseType(SbUseType.TZSB.getValue());
|
|
|
+ sbQuery.setPositionId(positionId);
|
|
|
+ sbQuery.setIsMeasure(YesNoEnum.YES.getValue());
|
|
|
+ Integer specialTotal = sbInfoMapper.countNum(sbQuery);
|
|
|
+ vo.setSpecialSbNum(new BigDecimal(specialTotal)); // 特种设备总数
|
|
|
+ sbQuery.setMeasureStatus(YesNoEnum.YES.getValue()); // 待检定
|
|
|
+ Integer waitNum = sbInfoMapper.countNum(sbQuery); // 待检定数量
|
|
|
+ vo.setSpecialCompleteRate(BigDecimalUtil.divPercent(new BigDecimal(specialTotal - waitNum),vo.getSpecialSbNum(),2));
|
|
|
+ // 计量设备和检定完成率
|
|
|
+ sbQuery.setUseType(SbUseType.BGCL.getValue());
|
|
|
+ sbQuery.setMeasureStatus(null);
|
|
|
+ Integer bgclTotal = sbInfoMapper.countNum(sbQuery); // 计量设备总数
|
|
|
+ vo.setCalculateSbNum(new BigDecimal(bgclTotal));
|
|
|
+ sbQuery.setMeasureStatus(YesNoEnum.YES.getValue()); // 待检定
|
|
|
+ Integer waitBgclNum = sbInfoMapper.countNum(sbQuery); // 待检定数量
|
|
|
+ vo.setSpecialCompleteRate(BigDecimalUtil.divPercent(new BigDecimal(bgclTotal - waitBgclNum),vo.getCalculateSbNum(),2));
|
|
|
+ // 隐患和转维修率
|
|
|
+
|
|
|
+ return r.setData(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getStatisticRepairNum() {
|
|
|
+ R r = new R();
|
|
|
+ List<RepairApplicationFormVO> result = ListUtils.newArrayList();
|
|
|
+ // 获取各个车间的报修数量和占比情况
|
|
|
+ List<RepairApplicationFormVO> list = repairApplicationFormService.selectCountByPosition(new RepairApplicationFormDTO());
|
|
|
+ if(list != null && list.size() > 0){
|
|
|
+ // 获取总数
|
|
|
+ int totalNum = 0;
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ RepairApplicationFormVO vo = list.get(i);
|
|
|
+ totalNum += vo.getRepairNum();
|
|
|
+ if(i <= 5){
|
|
|
+ result.add(list.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 计算占比
|
|
|
+ calculate(result,totalNum);
|
|
|
+ r.setData(result);
|
|
|
+ }else{
|
|
|
+ r.setData(null);
|
|
|
+ }
|
|
|
+ return r;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算车间维修占比
|
|
|
+ * @param result
|
|
|
+ * @param totalNum
|
|
|
+ */
|
|
|
+ private void calculate(List<RepairApplicationFormVO> result,int totalNum){
|
|
|
+ BigDecimal total = new BigDecimal(totalNum);
|
|
|
+ result.forEach(item -> {
|
|
|
+ item.setRepairRate(BigDecimalUtil.divPercent(new BigDecimal(item.getRepairNum()),total,2));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|